from pyecharts import Bar, WordCloud, Pie

name = ['饮料', '瓜子', '矿泉水']
value = [10, 20, 30]
value2 = [15, 25, 35]

# # 柱状图
# 设置标题,副标题
bar = Bar('食物', '零食')
# 设置主题
bar.use_theme('shine')
# 添加图表数据和设置项(显示中间值:mark_line=['average']。显示最大值和最小值:mark_point=['max', 'min'])
bar.add('food', name, value, mark_line=['average'], mark_point=['max', 'min'], is_more_utils=True)
bar.add('Snacks', name, value2, mark_line=['average'], mark_point=['max', 'min'], is_more_utils=True)
# 生成HTML文件
bar.render()

# 显示中间值:mark_line=['average']
# 显示最大值和最小值:mark_point=['max', 'min']

# # 词云图
wordcloud = WordCloud(width=1000, height=800)
wordcloud.use_theme('shine')
wordcloud.add('', name, value, word_size_range=[50, 100])
wordcloud.render()

# # 玫瑰图
# 设置标题居中,宽度为1000
pie = Pie('饼图-玫瑰图', title_pos='center', width=1000)
# 添加图标数据
pie.add('', name, value, center=[25, 50], radius=[30, 75])
pie.add('', name, value, center=[75, 50], radius=[30, 75], rosetype='area', is_legend_show=False, is_label_show=True)
pie.render()

# 设置居中显示坐标:center
# 设置图表半径:radius
# 设置玫瑰图类型:rosetype
# 刻印文字:is_legend_show=False
# 贴标签:is_label_show=True。

# # 自定义合并图
name = ['饮料', '瓜子', '矿泉水', '辣条', '啤酒', '娃哈哈']
value = [3, 5, 1, 6, 10, 2]
value2 = [5, 15, 3, 8, 15, 4]
bar = Bar('line-bar示例')
bar.add('bar', name, value)
line = Line()
line.add('line', name, value2)
# 重叠
overlap = Overlap()
overlap.add(bar)
overlap.add(line)
overlap.render()

 

Last modification:July 23rd, 2020 at 11:39 pm
如果觉得我的文章对你有用,请随意赞赏