您好,登錄后才能下訂單哦!
本文小編為大家詳細介紹“怎么用Pyecharts繪制常用的圖形”,內(nèi)容詳細,步驟清晰,細節(jié)處理妥當,希望這篇“怎么用Pyecharts繪制常用的圖形”文章能幫助大家解決疑惑,下面跟著小編的思路慢慢深入,一起來學習新知識吧。
from pyecharts.charts import Bar, Line, Grid from pyecharts import options # 1、準備數(shù)據(jù) country = ['巴西', '俄羅斯', '印度', '英國', '西班牙', '伊朗', '德國', '土耳其', '法國'] 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="我是標題", subtitle="我是副標題")) ) # 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é)果如下:
from pyecharts.charts import Bar, Line, Grid from pyecharts import options # 1、準備數(shù)據(jù) country = ['巴西', '俄羅斯', '印度', '英國', '西班牙', '伊朗', '德國', '土耳其', '法國'] 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="我是標題", subtitle="我是副標題"), 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é)果如下:
from pyecharts.charts import Bar, Line, Grid from pyecharts import options # 1、準備數(shù)據(jù) from pyecharts.charts import Bar, Line, Grid from pyecharts import options # 1、準備數(shù)據(jù) country = ['巴西', '俄羅斯', '印度', '英國', '西班牙', '伊朗', '德國', '土耳其', '法國'] 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="我是標題", subtitle="我是副標題")) ) # 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é)果如下:
讀到這里,這篇“怎么用Pyecharts繪制常用的圖形”文章已經(jīng)介紹完畢,想要掌握這篇文章的知識點還需要大家自己動手實踐使用過才能領(lǐng)會,如果想了解更多相關(guān)內(nèi)容的文章,歡迎關(guān)注億速云行業(yè)資訊頻道。
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。