Python強(qiáng)大的pyecharts繪畫優(yōu)美圖形<三>

繪制圖形: 儀表盤 - 漏斗圖 - 關(guān)系圖 - 水球 - 極坐標(biāo) - 雷達(dá)

from pyecharts import Funnel, Gauge, Graph
attr =["襯衫", "羊毛衫", "雪紡衫", "褲子", "高跟鞋", "襪子"]
v1 =[5, 20, 36, 56, 78, 100]
v2 =[55, 60, 16, 20, 15, 80]

儀表盤

# 儀表盤
gauge = Gauge("儀表盤")
gauge.add('業(yè)務(wù)指標(biāo)', '完成率', 66.66)
gauge.show_config()
gauge.render(path="./data/02-02儀表盤.html")
02-02儀表盤.png

漏斗圖

# 漏斗圖
funnel = Funnel('漏斗圖')
funnel.add('商品', attr, v1, is_label_show=True, label_pos='inside', label_text_color="#fff")
funnel.show_config()
funnel.render(path="./data/02-01漏斗圖.html")
02-01漏斗圖.png

關(guān)系圖

# 關(guān)系圖
nodes =[{"name": "結(jié)點(diǎn)1", "symbolSize": 10}, {"name": "結(jié)點(diǎn)2", "symbolSize": 20}, {"name": "結(jié)點(diǎn)3", "symbolSize": 30}, {"name": "結(jié)點(diǎn)4", "symbolSize": 40}, {"name": "結(jié)點(diǎn)5", "symbolSize": 50}, {"name": "結(jié)點(diǎn)6", "symbolSize": 40}, {"name": "結(jié)點(diǎn)7", "symbolSize": 30}, {"name": "結(jié)點(diǎn)8", "symbolSize": 20}]
links =[]
for i in nodes:
    for j in nodes:
        links.append({"source": i.get('name'), "target": j.get('name')})

print(links)
print(nodes)
graph =Graph("關(guān)系圖-環(huán)形布局示例")
graph.add("", nodes, links, is_label_show=True, repulsion=8000,     layout='circular', label_text_color=None)
graph.show_config()
graph.render(path="./data/02-03關(guān)系圖.html")

這個(gè)圖顯示的有問題,就不做展示了,如果后期找到正確的,我會(huì)在更新

from pyecharts import Liquid, Polar, Radar

水球

liquid =Liquid("水球圖")
liquid.add("Liquid", [0.6])
liquid.show_config()
liquid.render(path='./data/03-01水球.html')

# 圓形水球
liquid2 =Liquid("水球圖示例")
liquid2.add("Liquid", [0.6, 0.5, 0.4, 0.3], is_liquid_outline_show=False)
liquid2.show_config()
liquid2.render(path='./data/03-02圓形水球.html')

# 菱形水球
liquid3 =Liquid("水球圖示例")
liquid3.add("Liquid", [0.6, 0.5, 0.4, 0.3], is_liquid_animation=False, shape='diamond')
liquid3.show_config()
liquid3.render(path='./data/03-03菱形水球.html')
三個(gè)水球

極坐標(biāo)

# 極坐標(biāo)
radius =['周一', '周二', '周三', '周四', '周五', '周六', '周日']
polar =Polar("極坐標(biāo)系-堆疊柱狀圖示例", width=1200, height=600)
polar.add("A", [1, 2, 3, 4, 3, 5, 1], radius_data=radius, type='barRadius', is_stack=True)
polar.add("B", [2, 4, 6, 1, 2, 3, 1], radius_data=radius, type='barRadius', is_stack=True)
polar.add("C", [1, 2, 3, 4, 1, 2, 5], radius_data=radius, type='barRadius', is_stack=True)
polar.show_config()
polar.render(path='./data/03-04極坐標(biāo).html')
03-04極坐標(biāo).png

雷達(dá)圖

# 雷達(dá)圖
schema =[ ("銷售", 6500), ("管理", 16000), ("信息技術(shù)", 30000), ("客服", 38000), ("研發(fā)", 52000), ("市場(chǎng)", 25000)]
v1 =[[4300, 10000, 28000, 35000, 50000, 19000]]
v2 =[[5000, 14000, 28000, 31000, 42000, 21000]]
radar =Radar()
radar.config(schema)
radar.add("預(yù)算分配", v1, is_splitline=True, is_axisline_show=True)
radar.add("實(shí)際開銷", v2, label_color=["#4e79a7"], is_area_show=False)
radar.show_config()
radar.render(path='./data/03-05雷達(dá)圖.html')
03-05雷達(dá)圖.png

支持保存做種格式
對(duì)象.render(path='snapshot.html')
對(duì)象.render(path='snapshot.png')
對(duì)象.render(path='snapshot.pdf')
舉個(gè)栗子:

bar = Bar("我的第一個(gè)圖表", "這里是副標(biāo)題")
bar.add("服裝", ["襯衫", "羊毛衫", "雪紡衫", "褲子", "高跟鞋", "襪子"], [5, 20, 36, 10, 75, 90])
# bar.print_echarts_options()
bar.render(path='snapshot.html')
bar.render(path='snapshot.png')
bar.render(path='snapshot.pdf')

pyecharts繪畫優(yōu)美圖形<一>:最全地圖
pyecharts繪畫優(yōu)美圖形<二>:柱形圖-折線圖-餅圖
pyecharts繪畫優(yōu)美圖形<三>:儀表盤 - 漏斗圖 - 關(guān)系圖 - 水球 - 極坐標(biāo) - 雷達(dá)
pyecharts繪畫優(yōu)美圖形<四>:詞云--支持中文

關(guān)注公眾號(hào):Python瘋子 后臺(tái)回復(fù): pyecharts 獲取源代碼
分享最實(shí)用的Python功能,歡迎您的關(guān)注

Python瘋子.jpg
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容