首页 > 解决方案 > ValueError:使用 plt.show() 时第 0 年超出范围

问题描述

我是 python 新手,我尝试绘制图表,但它一直给我一个错误,说“ValueError:第 0 年超出范围”。有人知道我的代码发生了什么吗?你能给我一些关于如何解决它的建议吗?非常感激!

下面是 actual_predictions 值的截图: 在此处输入图片描述

下面是 x 值的截图: 在此处输入图片描述

下面是绘制图形的代码:

plt.title('Month vs total diverted')
plt.ylabel('Total total diverted')
plt.grid(True)
plt.autoscale(axis='x', tight=True)
#import pdb; pdb.set_trace()
plt.plot(df['Total_Surface_Water_Diverted'][-train_window:])
plt.plot(x,actual_predictions)
plt.show()

标签: pythonvalueerror

解决方案


推荐阅读