【发布时间】:2018-09-18 06:33:37
【问题描述】:
我正在绘制一个带有折线图的面积图作为数据框结构顶部的衬里,如下所示:
df = pd.DataFrame({'Date':pd.date_range('2018-1-1', periods=100, freq='D'),'Pre1':np.random.randint(-1000, 1000, 100),
'Pre2':np.random.randint(-750, 1000, 100)},
columns=['Date','Pre1','Pre2'])
df=df.set_index('Date')
和
DatetimeIndex(['2017-01-01', '2017-01-03', '2017-01-04', '2017-01-05',
'2017-01-06', '2017-01-09', '2017-01-10', '2017-01-11',
'2017-01-12', '2017-01-13',
...
'2018-08-29', '2018-08-30', '2018-08-31', '2018-09-03',
'2018-09-04', '2018-09-05', '2018-09-06', '2018-09-07',
'2018-09-10', '2018-09-11'],
dtype='datetime64[ns]', name='Date', length=416, freq=None)
我正在使用
plt.figure()
ax3=df.plot(df.index,'Pre1', color="g",linewidth=0.8) #the line
plt.fill_between(df.index,df['Pre1'], facecolor="palegreen", alpha=0.4) # the area
ax3.tick_params(axis="x",direction="in")
ax3.tick_params(axis="y",direction="in")
plt.text(1,100,'Pre')
plt.text(3,-100,'Dis')
plt.ylabel('$')
ax3.legend().set_visible(False)
plt.title('This is a test')
plt.xticks()
ax3.yaxis.grid(True,linestyle='--')
plt.show()
但是,我得到了以下错误:
ValueError: Image size of 362976x273 pixels is too large. It must be less than 2^16 in each direction.
我曾尝试重新启动内核以及 Jupyter,但没有成功。还尝试了 figsize=(6,8),不工作。有谁知道问题出在哪里?
【问题讨论】:
标签: matplotlib