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')
python数据可视化——echarts
最新推荐文章于 2023-09-25 22:34:50 发布