Pyecharts?繪制3種常用的圖形
大家好,今天給大家利用 Pyecharts 繪制上下組合圖、左右組合圖、一軸多圖,好用超經(jīng)典,分析給大家
1.上下組合
from pyecharts.charts import Bar, Line, Grid from pyecharts import options # 1、準(zhǔn)備數(shù)據(jù) country = ['巴西', '俄羅斯', '印度', '英國(guó)', '西班牙', '伊朗', '德國(guó)', '土耳其', '法國(guó)'] quezheng = [923189,553301,354065,298136,244328,192439,188252,181298,157716] siwang = [45241,7478,11903,41969,27136,9065,8802,4842,29547] # 2、繪制柱形圖 bar = ( ? ? Bar() ? ? .add_xaxis(country) ? ? .add_yaxis("確診人數(shù)", quezheng) ? ? .add_yaxis("死亡人數(shù)", siwang) ? ? .set_global_opts(title_opts=options.TitleOpts(title="我是標(biāo)題", subtitle="我是副標(biāo)題")) ) # 3、繪制線圖 line = ( ? ? Line() ? ? .add_xaxis(country) ? ? .add_yaxis("quzheng人數(shù)", quezheng) ? ? .add_yaxis("siwang人數(shù)", siwang) ? ? .set_global_opts(legend_opts=opts.LegendOpts(pos_bottom="45%")) ) # 4、創(chuàng)建組合圖 (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()
結(jié)果如下:
2.左右組合
from pyecharts.charts import Bar, Line, Grid from pyecharts import options # 1、準(zhǔn)備數(shù)據(jù) country = ['巴西', '俄羅斯', '印度', '英國(guó)', '西班牙', '伊朗', '德國(guó)', '土耳其', '法國(guó)'] quezheng = [923189,553301,354065,298136,244328,192439,188252,181298,157716] siwang = [45241,7478,11903,41969,27136,9065,8802,4842,29547] # 2、繪制柱形圖 bar = ( ? ? Bar() ? ? .add_xaxis(country) ? ? .add_yaxis("確診人數(shù)", quezheng, label_opts=opts.LabelOpts(is_show=False)) ? ? .add_yaxis("死亡人數(shù)", siwang, label_opts=opts.LabelOpts(is_show=False)) ? ? .set_global_opts(title_opts=options.TitleOpts(title="我是標(biāo)題", subtitle="我是副標(biāo)題"), ? ? ? ? ? ? ? ? ? ? ?legend_opts=opts.LegendOpts(pos_right="20%")) ) # 3、繪制線圖 line = ( ? ? Line() ? ? .add_xaxis(country) ? ? .add_yaxis("quzheng人數(shù)", quezheng, label_opts=opts.LabelOpts(is_show=False)) ? ? .add_yaxis("siwang人數(shù)", siwang, label_opts=opts.LabelOpts(is_show=False)) ? ? .set_global_opts(legend_opts=opts.LegendOpts(pos_left="20%")) ) # 4、創(chuàng)建組合圖 (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()
結(jié)果如下:
3.一軸多圖
from pyecharts.charts import Bar, Line, Grid from pyecharts import options # 1、準(zhǔn)備數(shù)據(jù) from pyecharts.charts import Bar, Line, Grid from pyecharts import options # 1、準(zhǔn)備數(shù)據(jù) country = ['巴西', '俄羅斯', '印度', '英國(guó)', '西班牙', '伊朗', '德國(guó)', '土耳其', '法國(guó)'] quezheng = [923189,553301,354065,298136,244328,192439,188252,181298,157716] siwang = [45241,7478,11903,41969,27136,9065,8802,4842,29547] # 2、繪制柱形圖 bar = ( ? ? Bar(init_opts=opts.InitOpts(width='750px', height='350px')) ? ? .add_xaxis(country) ? ? .add_yaxis("確診人數(shù)", quezheng) ? ? .add_yaxis("死亡人數(shù)", siwang) ? ? .set_global_opts(title_opts=options.TitleOpts(title="我是標(biāo)題", subtitle="我是副標(biāo)題")) ) # 3、繪制線圖 line = ( ? ? Line() ? ? .add_xaxis(country) ? ? .add_yaxis("確診人數(shù)", quezheng, label_opts=opts.LabelOpts(is_show=False)) ? ? .add_yaxis("死亡人數(shù)", siwang, label_opts=opts.LabelOpts(is_show=False)) ) # 4、創(chuàng)建組合圖 bar.overlap(line).render_notebook()
結(jié)果如下:
到此這篇關(guān)于Pyecharts 繪制3種常用的圖形的文章就介紹到這了,更多相關(guān)Pyecharts 繪制常用的圖形內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
在Python中編寫(xiě)數(shù)據(jù)庫(kù)模塊的教程
這篇文章主要介紹了在Python中編寫(xiě)數(shù)據(jù)庫(kù)模塊的教程,本文代碼基于Python2.x版本,需要的朋友可以參考下2015-04-04基于Python的身份證驗(yàn)證識(shí)別和數(shù)據(jù)處理詳解
這篇文章主要介紹了基于Python的身份證驗(yàn)證識(shí)別和數(shù)據(jù)處理,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-11-11python微信跳一跳系列之自動(dòng)計(jì)算跳一跳距離
這篇文章主要為大家詳細(xì)介紹了python微信跳一跳系列之自動(dòng)計(jì)算跳一跳距離,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-02-02Python 刪除List元素的三種方法remove、pop、del
這篇文章主要介紹了Python 刪除List元素的三種方法remove、pop、del,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-11-11python利用hook技術(shù)破解https的實(shí)例代碼
python利用hook技術(shù)破解https的實(shí)例代碼,需要的朋友可以參考一下2013-03-03解決python腳本中error: unrecognized arguments: True錯(cuò)誤
這篇文章主要介紹了解決python腳本中error: unrecognized arguments: True錯(cuò)誤,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-04-04用OpenCV進(jìn)行年齡和性別檢測(cè)的實(shí)現(xiàn)示例
這篇文章主要介紹了用 OpenCV 進(jìn)行年齡和性別檢測(cè)的實(shí)現(xiàn)示例,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2021-01-01詳解pycharm自動(dòng)import所需的庫(kù)的操作方法
這篇文章主要介紹了pycharm自動(dòng)import所需的庫(kù)的操作方法,本文通過(guò)圖文并茂的形式給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-11-11