1. 程式人生 > >Python 利用 pyecharts 做資料分析繪圖

Python 利用 pyecharts 做資料分析繪圖

柱狀圖

from pyecharts import Bar
bar = Bar("柱狀圖")
bar.add("服裝", ["襯衫", "羊毛衫", "雪紡衫", "褲子", "高跟鞋", "襪子"], [5, 20, 36, 10, 75, 90])
bar.add("鞋子", ["的薩芬", "士大夫", "暗示法", "農安", "額", "全球"], [5, 20, 36, 10, 75, 90])
# bar.print_echarts_options()

在這裡插入圖片描述

餅狀圖

from pyecharts import Pie
columns = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
data1 = [2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3]
data2 = [2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3]
pie = Pie('餅狀圖','一年的降水量與蒸發量')
pie.add('降水量', columns, data1, center=[25,50], is_legend_show=False)
pie.add('蒸發量', columns, data2, center=[75,50], is_legend_show=False, is_label_show=True)

在這裡插入圖片描述

折線圖

from pyecharts import Line
line = Line('折線圖')
line.add("降水量", columns, data1, is_label_show=True)
line.add("蒸發量", columns, data2, is_label_show=True)

在這裡插入圖片描述

儀表盤

from pyecharts import Funnel, Gauge, Graph
gauge = Gauge('儀表盤')
gauge.add('業務指標', '完成率', 60)
# gauge.show_config()

在這裡插入圖片描述

詞雲

from pyecharts import WordCloud
from scipy.misc import imread
name =['Sam S Club', 'Macys', 'Amy Schumer', 'Jurassic World', 'Charter Communications', 'Chick Fil A', 'Planet Fitness', 'Pitch Perfect', 'Express', 'Home', 'Johnny Depp', 'Lena Dunham', 'Lewis Hamilton', 'KXAN', 'Mary Ellen Mark', 'Farrah Abraham', 'Rita Ora', 'Serena Williams', 'NCAA baseball tournament', 'Point Break']
value =[10000, 6181, 4386, 4055, 2467, 2244, 1898, 1484, 1112, 965, 847, 582, 555, 550, 462, 366, 360, 282, 273, 265]
wordcloud = WordCloud(width=600, height=400)
wordcloud.add("", name, value, word_size_range=[20, 100])

在這裡插入圖片描述