#导入库
from pyecharts import options as opts
from pyecharts.charts import Bar, Line
#准备数据
x_years = (list(range(2014,2022)))
x_years_str = [str(year) for year in x_years]
y1 = [7.40, 4.00, 5.83, 5.81, 5.16, 8.63, -9.13, 13.66]
y2 = [87430, 90912, 96225, 101885, 107147, 116390, 105764, 120215]
#柱形图
bar = (
Bar()
.add_xaxis(x_years)
.add_yaxis("诊疗量", y2)
.extend_axis(
yaxis=opts.AxisOpts(
axislabel_opts=opts.LabelOpts(formatter="{value} %"), interval=5,
)
)
#.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
#设置全局配置项
.set_global_opts(
title_opts=opts.TitleOpts(title='2014-2021年中国中医类医疗卫生机构诊疗量'),
yaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(formatter="{value} 万人次")),
)
)
# 折线图
line =(
Line()
.add_xaxis(x_years_str)
.add_yaxis("同比增速", y1, yaxis_index=1, z=2)
)
bar.overlap(line)#将折线图叠加到柱形图上
bar.render("overlap_bar_line.html")
pyecharts绘制柱形折线图
最新推荐文章于 2024-07-12 16:26:30 发布