# 引入相关的库
from pyecharts.charts import Line
import pyecharts.options as opts
import pandas as pd
from pyecharts.globals import ThemeType
# 导入数据
df = pd.read_csv('data/beijing_AQI_2018.csv')
attr = df['Date'].tolist()
v1 = df['AQI'].tolist()
# 函数具体实现内容
(
Line(init_opts=opts.InitOpts(theme=ThemeType.DARK)) # 设置背景主题类型
.add_xaxis(attr)
.add_yaxis("AQI值", v1,
markline_opts=opts.MarkLineOpts(data=[opts.MarkLineItem(type_='average')]),
markpoint_opts=opts.MarkPointOpts(data=[opts.MarkPointItem(type_='max'),
opts.MarkPointItem(type_='min')])
)
.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
.set_global_opts(
title_opts=opts.TitleOpts(title='2018年北京AQI全年走势图')
,yaxis_opts=opts.AxisOpts(splitline_opts=opts.SplitLineOpts(is_show=True))
)
.render_notebook()
)
2018年北京AQI全年走势图
最新推荐文章于 2021-02-03 20:58:56 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)