1.
# -*-coding:gb2312-*-
from pyecharts.charts import Line
from pyecharts import options as opts
from pyecharts.globals import ThemeType #主题风格库
# 准备数据
str1 = ['张三', '李四', '王五', '马六', '包青天']
s1 = [70, 56, 82, 46, 96]
s2 = [46, 56, 86, 96, 23]
s3 = [75, 36, 56, 84, 91]
line = (
Line(init_opts=opts.InitOpts(theme=ThemeType.VINTAGE))
.add_xaxis(str1) # 绘制x轴
.add_yaxis('语文成绩', s1) # 绘制y轴
.add_yaxis('数学成绩', s2)
.add_yaxis('英语成绩', s3)
.set_global_opts(title_opts=opts.TitleOpts(title='期末考试', subtitle='2022学年'))) # 主标题:title=, 副标题:subtitle=
line.render('柱形图02.html')