import numpy as np
from pyecharts.charts import Bar
from pyecharts import options as opts
from pyecharts.globals import ThemeType

# 生成数据
years = [2011, 2012, 2013, 2014, 2015]
y1 = [1, 3, 5, 7, 9]
y2 = [2, 4, 6, 4, 2]
y3 = [9, 7, 5, 3, 1]
y4 = list(np.random.randint(1, 10, 10))

bar = Bar(init_opts=opts.InitOpts(theme=ThemeType.LIGHT))
# 为柱状图添加x轴和y轴数据
bar.add_xaxis(years)
bar.add_yaxis('A型', y1)
bar.add_yaxis('B型', y2)
bar.add_yaxis('C型', y3)
bar.add_yaxis('D型', y4)
# 渲染图表到HTML文件,并保存在当前目录下
show()