Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize data Visualization with pyecharts

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how pyecharts can realize data visualization. Xiaobian thinks it is quite practical, so share it with you for reference. I hope you can gain something after reading this article.

1. overview

Pyecharts is Baidu open source, suitable for data visualization tools, flexible configuration, relatively beautiful display charts, smooth.

2. installation

Installation in Python 3 environment:

pip3 install pyecharts3. Data visualization code 3.1 histogram from pyecharts import options as optsfrom pyecharts.charts import Barfrom pyecharts.faker import Faker c = ( Bar() .add_xaxis(Faker.choose()) .add_yaxis("Merchant A", Faker.values(), stack="stack1") .add_yaxis("Merchant B", Faker.values(), stack="stack1") .set_series_opts(label_opts=opts.LabelOpts(is_show=False)) .set_global_opts(title_opts=opts.TitleOpts(title="Bar-Stacked Data (All)")) .render("bar_stack0.html"))

Executing the above code will generate mycharts.html file in relative directory, which will be opened through page.

3.2 Line charts import pyecharts.options as optsfrom pyecharts.charts import Line ""Gallery use pyecharts 1.1.0 Reference: https://echarts.apache.org/examples/editor.html? c=line-smooth Currently unavailable function: None "" x_data = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]y_data = [820, 932, 901, 934, 1290, 1330, 1320] ( Line() .set_global_opts( tooltip_opts=opts.TooltipOpts(is_show=False), xaxis_opts=opts.AxisOpts(type_="category"), yaxis_opts=opts.AxisOpts( type_="value", axistick_opts=opts.AxisTickOpts(is_show=True), splitline_opts=opts.SplitLineOpts(is_show=True), ), ) .add_xaxis(xaxis_data=x_data) .add_yaxis( series_name="", y_axis=y_data, symbol="emptyCircle", is_symbol_show=True, is_smooth=True, label_opts=opts.LabelOpts(is_show=False), ) .render("smoothed_line_chart.html"))

3.3 pie chart from pyecharts import options as optsfrom pyecharts.charts import Piefrom pyecharts.faker import Faker c = ( Pie() .add( "", [list(z) for z in zip(Faker.choose(), Faker.values())], radius=["40%", "75%"], ) .set_global_opts( title_opts=opts.TitleOpts(title="Pie-Radius"), legend_opts=opts.LegendOpts(orient="vertical", pos_top="15%", pos_left="2%"), ) .set_series_opts(label_opts=opts.LabelOpts(formatter="{b}: {c}")) .render("pie_radius.html"))

About "pyecharts how to achieve data visualization" this article is shared here, I hope the above content can be of some help to everyone, so that you can learn more knowledge, if you think the article is good, please share it to let more people see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report