from pyecharts.charts import Bar
from pyecharts import options as opts
# 示例数据
cate = ["化学药", "中成药", "生物制品", "中药颗粒", "中药饮片", "保健品"]
data1 = [33, 45, 12, 13, 4, 4]
data2 = [16, 14, 2, 4, 30, 33]
bar = (Bar()
.add_xaxis(cate)
.add_yaxis('云南白药', data1,color='red',
markpoint_opts=opts.MarkPointOpts(data=[opts.MarkPointItem(type_="max")]))
.add_yaxis('同仁堂', data2,color='green',
markpoint_opts=opts.MarkPointOpts(data=[opts.MarkPointItem(type_="max")]))
.set_global_opts(title_opts=opts.TitleOpts(title="两家公司各种品类药物销售额(柱形图)",pos_left='center',subtitle="云南白药和同仁堂"),
yaxis_opts=opts.AxisOpts(name="销售额(亿元)"),
legend_opts=opts.LegendOpts(pos_left='70%' ))
)
bar.render_notebook()
用pyecharts完成数据可视化柱形图
最新推荐文章于 2024-10-07 13:46:40 发布