我希望纵轴的间隔也是10,从1到100
时间: 2024-04-17 13:24:16 浏览: 14
非常抱歉,我之前的回答有误。要将纵轴的间隔设置为10,您可以使用 `yaxis_opts` 的 `axislabel_opts` 参数,并将其设置为 `interval=10`。
以下是修改后的代码:
```python
import pandas as pd
from pyecharts import options as opts
from pyecharts.charts import Scatter
# 读取Excel文件
data = pd.read_excel('6004020918.xlsx')
# 提取数据
week = data['week']
need = data['need']
# 创建散点图对象
scatter = Scatter()
scatter.set_global_opts(title_opts=opts.TitleOpts(title='6004020918'))
# 设置图例
legend_data = ['需求']
scatter.add_xaxis(week)
scatter.add_yaxis(legend_data[0], need, symbol_size=10)
# 设置坐标轴名称和间隔
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}))
# 显示中文标签
scatter.set_series_opts(label_opts=opts.LabelOpts(is_show=True, position='right'))
# 生成HTML文件
scatter.render('scatter_chart.html')
```
请注意,我将纵轴的 `split_number` 设置为10,并使用了 `axislabel_opts` 的 `interval` 参数将刻度间隔设置为10。请尝试使用这个修正后的代码,并检查是否还有其他可能导致问题的错误。如果问题仍然存在,请提供完整的错误消息和堆栈跟踪,以便更好地帮助您解决问题。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)