Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use Pyecharts to draw commonly used graphs

Shulou Source: shulou.com Published: 2022-06-01 12:16:32 10月03日 Update

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.

Tags: Number of people combination data preparation graphics common use subtitle article title line graph result Iran Russia India Turkey Brazil Germany France United Kingdom Spain Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Shulou Technology MySQL Microsoft OPPO Reno