一,数据导入
表. 全国药店中药饮片供应商占比情况
年份(年) | 跨国企业占比(%) | 本土企业占比(%) |
2019 | 20.3 | 79.7 |
2020 | 22.0 | 78.0 |
2021 | 23.5 | 76.5 |
2022 | 22.5 | 77.5 |
2023 | 22.3 | 77.7 |
二,运行代码
from pyecharts import options as opts
from pyecharts.charts import Bar
from pyecharts.globals import ThemeType
#数据准备
year_data = [2019,2020,2021,2022,2023]
list2 = [20.0,22.0,23.5,22.5,22.3]
list3 = [79.7,78.0,76.5,77.5,77.7]
c = (
Bar(init_opts=opts.InitOpts(theme=ThemeType.LIGHT))
.add_xaxis(year_data)
.add_yaxis("跨国企业占比(%)", list2, stack="stack1", category_gap="60%")
.add_yaxis("本土企业占比(%)", list3, stack="stack1", category_gap="60%")
.set_series_opts(
label_opts=opts.LabelOpts(
position="right")
)
.set_global_opts(title_opts=opts.TitleOpts(title="全国药店中药饮片供应商占比情况"))
.render("堆积柱形图.html")
)