绘制学生成绩比较分析折线图
话不多说,直接上代码:
from pyecharts import options as opts
from pyecharts.charts import Line, Page
from faker import Faker
fak = Faker(locale='zh_CN')
x_data = [fak.name() for _ in range(10)]
y_data = [fak.pyfloat(left_digits=2, right_digits=2, positive=True) for _ in range(10)]
# 绘制折线图
def line_toolbox() -> Line:
line = (
Line()
.add_xaxis(x_data)
.add_yaxis("成绩", y_data, is_smooth=True) # is_smooth默认是False,即折线
.set_global_opts(
title_opts=opts.TitleOpts(title="学生成绩比较分析"),
toolbox_opts=opts.ToolboxOpts(),
legend_opts=opts.LegendOpts(is_show=True, po