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 use Pyecharts to draw commonly used graphs

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article is a detailed introduction to "how to draw commonly used graphics with Pyecharts". The content is detailed, the steps are clear, and the details are properly handled. I hope this article "how to draw commonly used graphics with Pyecharts" can help you solve your doubts. Let's go deeper and learn new knowledge together with the ideas of the small editor.

1. combination from pyecharts.charts import Bar, Line, Gridfrom pyecharts import options #1, prepare data country = ['Brazil',' Russia','India',' Britain','Spanish',' Iran','Germany',' Turkey','France'] quezheng = [923189,553301,354065,298136,244328,192439, 188252,181298,157716]siwang = [45241,7478,11903,41969,27136,9065,8802,4842,29547]# 2. Draw bar = ( Bar() .add_xaxis(country) .add_yaxis("Number of confirmed cases", quezheng) .add_yaxis("Number of deaths", siwang) .set_global_opts(title_opts=options.TitleOpts(title="I am the title", subtitle="I am the subtitle"))# 3. Draw line = ( Line() .add_xaxis(country) .add_yaxis("quzheng number", quezheng) .add_yaxis("siwang number", siwang) .set_global_opts(legend_opts=opts.LegendOpts(pos_bottom="45%"))#4. Create a composition graph (Grid(init_opts=opts.InitOpts(width='750px', height='350px')) .add(bar,grid_opts=opts.GridOpts(pos_bottom="60%")) .add(line,grid_opts=opts.GridOpts (pos_top="60%")).render_notebook()

The results were as follows:

2. left and right combinations from pyecharts.charts import Bar, Line, Gridfrom pyecharts import options #1, Prepare data country = ['Brazil',' Russia','India',' Britain','Spanish',' Iran','Germany',' Turkey','France'] quezheng = [923189,553301,354065,298136,244328,192439, 188252,181298,157716]siwang = [45241,7478,11903,41969,27136,9065,8802,4842,29547]# 2. Draw bar = ( Bar() .add_xaxis(country) .add_yaxis("Number of confirmed cases", quezheng, label_opts=opts.LabelOpts(is_show=False)) .add_yaxis("Number of deaths", siwang, label_opts=opts.LabelOpts(is_show=False)) .set_global_opts(title_opts=options.TitleOpts(title="I am the title", subtitle="I am the subtitle"), Legend_opts=opts.LegendOpts(pos_right="20%"))# 3, Draw line = ( Line() .add_xaxis(country) .add_yaxis("quzheng number", quezheng, label_opts=opts.LabelOpts(is_show=False)) .add_yaxis("siwang", siwang, label_opts=opts.LabelOpts(is_show=False)) .set_global_opts(legend_opts=opts.LegendOpts(pos_left="20%"))#4. Create a composite graph (Grid(init_opts=opts.InitOpts(width='750px', height='350px')) .add(bar,grid_opts=opts.GridOpts(pos_left="55%")) .add(line,grid_opts=opts.GridOpts(pos_right="55%")).render_notebook()

The results were as follows:

3. 1-axis multigraph from pyecharts.charts import Bar, Line, Gridfrom pyecharts import options #1, Prepare data from pyecharts.charts import Bar, Line, Gridfrom pyecharts import options #1, Prepare data country = ['Brazil',' Russia','India',' Britain','Spanish',' Iran','Germany',' Turkey','France'] quezheng = [923189,553301, 354065,298136,244328,192439,188252,181298,157716]siwang = [45241,7478,11903,41969,27136,9065,8802,4842,29547]# 2. Draw bar = ( Bar(init_opts=opts.InitOpts(width='750px', height='350px')) .add_xaxis(country) .add_yaxis("Number of confirmed cases", quezheng) .add_yaxis("Number of deaths", siwang) .set_global_opts(title_opts=options.TitleOpts(title="I am the title", subtitle="I am the subtitle"))# 3. Draw line = ( Line() .add_xaxis(country) .add_yaxis("Number of confirmed cases", quezheng, label_opts=opts.LabelOpts(is_show=False)) .add_yaxis("Number of deaths", siwang, label_opts=opts.LabelOpts(is_show=False))# 4. Create a composite graph bar.overlap(line).render_notebook()

The results were as follows:

Read here, this article "How to draw commonly used graphics with Pyecharts" has been introduced, want to master the knowledge points of this article still need to be used by yourself to understand, if you want to know more about the relevant content of the article, welcome to pay attention to the industry information channel.

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