Python強大的pyecharts繪畫優美圖形<三>

繪制圖形: 儀表盤 - 漏斗圖 - 關系圖 - 水球 - 極坐標 - 雷達

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('業務指標', '完成率', 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

關系圖

# 關系圖
nodes =[{"name": "結點1", "symbolSize": 10}, {"name": "結點2", "symbolSize": 20}, {"name": "結點3", "symbolSize": 30}, {"name": "結點4", "symbolSize": 40}, {"name": "結點5", "symbolSize": 50}, {"name": "結點6", "symbolSize": 40}, {"name": "結點7", "symbolSize": 30}, {"name": "結點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("關系圖-環形布局示例")
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關系圖.html")

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

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')
三個水球

極坐標

# 極坐標
radius =['周一', '周二', '周三', '周四', '周五', '周六', '周日']
polar =Polar("極坐標系-堆疊柱狀圖示例", 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極坐標.html')
03-04極坐標.png

雷達圖

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

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

bar = Bar("我的第一個圖表", "這里是副標題")
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繪畫優美圖形<一>:最全地圖
pyecharts繪畫優美圖形<二>:柱形圖-折線圖-餅圖
pyecharts繪畫優美圖形<三>:儀表盤 - 漏斗圖 - 關系圖 - 水球 - 極坐標 - 雷達
pyecharts繪畫優美圖形<四>:詞云--支持中文

關注公眾號:Python瘋子 后臺回復: pyecharts 獲取源代碼
分享最實用的Python功能,歡迎您的關注

Python瘋子.jpg
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容