python資料視覺化——echarts

weixin_39928244發表於2018-10-16
from pyecharts import Bar, Pie, Scatter, Gauge, HeatMap, Funnel, WordCloud, Line, Grid
'''
attr = ['襯衫', '羊毛衫', '雪紡衫', '褲子', '高跟鞋', '襪子']
v1 = [5, 20, 36, 10, 75, 90]
v2 = [10, 25, 8, 60, 20, 80]
bar = Bar('各商家產品銷售情況')
bar.add('商家A', attr, v1, is_stack=True)
bar.add('商家B', attr, v2, is_stack=True)
bar.render('bar.html')

attr = ['襯衫', '羊毛衫', '雪紡衫', '褲子', '高跟鞋', '襪子']
v1 = [11, 12, 13, 10, 10, 10]
pie = Pie('各產品銷售情況')
pie.add('', attr, v1, is_label_show=True)
pie.render('pie.html')

attr = ['襯衫', '羊毛衫', '雪紡衫', '褲子', '高跟鞋', '襪子']
v1 = [11, 12, 13, 10, 10, 10]
pie = Pie('餅圖-圓環圖示例', title_pos='center')
pie.add('', attr, v1, radius=[40, 75], label_text_color=None,
        is_label_show=True, legend_orient='vertical',
        legend_pos='left')
pie.render('circle_pie.html')

v1 = [10, 20, 30, 40, 50, 60]
v2 = [10, 20, 30, 40, 50, 60]
scatter = Scatter('散點圖示例')
scatter.add('A', v1, v2)
scatter.add('B', v1[::-1], v2)
scatter.render('scatter.html')

gauge = Gauge('業務指標完成率-儀表盤')
gauge.add('業務指標', '完成率', 66.66)
gauge.render('gauge.html')

attr = ['潛在', '接觸', '意向', '明確', '投入', '談判', '成交']
value = [140, 120, 100, 80, 60, 40, 20]
funnel = Funnel('銷售管理分析漏斗圖')
funnel.add('商品', attr, value, is_label_show=True, label_pos='inside', label_text_color='#fff')
funnel.render('funnel.html')

name = ['Sam S Club', 'Macys', 'Amy Schumer', 'Jurassic World', 'Charter Communications',
        'Chick Fill 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, 184, 1112,
         965, 847, 582, 555, 550, 462, 366, 360, 282, 273, 265]
wordcloud = WordCloud(width=1300, height=620)
wordcloud.add('', name, value, word_size_range=[20, 100])
wordcloud.render('wordcloud.html')
'''
line = Line('折線圖', width=1200)
attr = ['週一', '週二', '週三', '週四', '週五', '週六', '週日']
line.add('最高氣溫', attr, [11, 11, 15, 13, 12, 13, 10], mark_point=['max', 'min'], mark_line=['average'])
line.add('最低氣溫', attr, [1, -2, 2, 5, 3, 2, 0], mark_point=['max', 'min'], mark_line=['average'], legend_pos='20%')
attr = ['襯衫', '羊毛衫', '雪紡衫', '褲子', '高跟鞋', '襪子']
v1 = [11, 12, 13, 10, 10, 10]
pie = Pie('餅圖', title_pos='55%')
pie.add('', attr, v1, radius=[45, 65], center=[65, 50], legend_pos='80%', legend_orient='vertical')
grid = Grid()
grid.add(line, grid_right='55%')
grid.add(pie, grid_left='60%')
grid.render('grid.html')

相關文章