import pandas as pd from pyecharts import options as opts from pyecharts.charts import Scatter # 读取Excel文件 data = pd.read_excel('6004021055.xlsx') # 提取数据 week = data['week'] need = data['need'] # 创建散点图对象 scatter = Scatter() scatter.set_global_opts( xaxis_opts=opts.AxisOpts(name='week', split_number=18, interval=10), yaxis_opts=opts.AxisOpts(name='need', split_number=10, interval=10, axislabel_opts={"interval": 10}), title_opts=opts.TitleOpts(title='6004021055') ) # 设置图例 legend_data = ['需求'] scatter.add_xaxis(week) scatter.add_yaxis(legend_data[0], need, symbol_size=10) # 显示中文标签 scatter.set_series_opts(label_opts=opts.LabelOpts(is_show=True, position='right')) # 生成HTML文件 scatter.render('scatter_chart_6004021055.html')帮我把这段代码从绘制散点图修改成绘制折线图,要求在点上不显示数据
时间: 2024-04-17 09:25:34 浏览: 111
Python代码源码-实操案例-框架案例-如何生成动态图表(pyecharts模块).zip
好的,我将把代码从绘制散点图修改为绘制折线图,并且在数据点上不显示数据。以下是修改后的代码:
```python
import pandas as pd
from pyecharts import options as opts
from pyecharts.charts import Line
# 读取Excel文件
data = pd.read_excel('6004021055.xlsx')
# 提取数据
week = data['week']
need = data['need']
# 创建折线图对象
line = Line()
line.set_global_opts(
xaxis_opts=opts.AxisOpts(name='week', split_number=18, interval=10),
yaxis_opts=opts.AxisOpts(name='need', split_number=10, interval=10, axislabel_opts={"interval": 10}),
title_opts=opts.TitleOpts(title='6004021055')
)
# 设置图例
legend_data = ['需求']
line.add_xaxis(week)
line.add_yaxis(legend_data[0], need, is_smooth=True, label_opts=opts.LabelOpts(is_show=False))
# 生成HTML文件
line.render('line_chart_6004021055.html')
```
这样修改后,代码将绘制折线图,并且在数据点上不显示数据。
阅读全文