我在一张图上画了两条线,我想在中间的区域加上阴影,但是我做不到,我的数据是2个数据帧,有365个观察值。 我当前的代码如下所示。在
plt.figure()
plt.plot(minimos, '', maximos, '')
plt.scatter(df6x, df6, s=50, c='r', alpha=0.8)
plt.scatter(df5x, df5, s=50, c='b', alpha=0.8)
plt.legend(['High', 'Low'])
关于数据帧的更多信息
^{pr2}$但我仍然有ValueError的问题:参数维度不兼容
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
maximos = maximos.values
minimos = minimos.values
x = np.arange(0,365,1)
x = x.reshape(365,1)
fig = plt.figure()
plt.plot(x, maximos, c='r', alpha=0.8)
plt.plot(x, minimos, c='b', alpha=0.8)
# fill between hgh and low
ax = fig.gca()
ax.fill_between(x, minimos, maximos, facecolor='purple')
plt.legend(['High', 'Low'])
plt.scatter(df6x, df6, s=50, c='r', alpha=0.8)
plt.scatter(df5x, df5, s=50, c='b', alpha=0.8)
错误在这行代码中ax.填充(x,minimos,maximos,facecolor='purple')。在
这里没有理由使用
x = x.reshape(365,1)
。整形x
会使参数维度不兼容,如错误所示。省略这一行将使代码生效:使用
fill_between
:http://matplotlib.org/examples/pylab_examples/fill_between_demo.html相关问题 更多 >
编程相关推荐