我想绘制一些随季节变化的时间序列,并使用 axvspan 将冬季的部分阴影与夏季的部分阴影不同。我正在使用pyplot.plot_date。我的 y 值是一个 np 浮点数组,我的 x 值是一个使用转换的日期时间对象的 np 数组
datetime.strptime(date, '%m-%d-%Y').
Run Code Online (Sandbox Code Playgroud)
我想使用pyplot.axvspan来应用阴影,但它似乎只适用于 x 轴的常规数字,而我的 x 轴是日期。我遇到的错误是
ValueError: view limit minimum -36858.05 is less than 1 and is an invalid Matplotlib date value. This often happens if you pass a non-datetime value to an axis that has datetime units
Run Code Online (Sandbox Code Playgroud)
有什么办法可以解决这个问题?