【发布时间】:2021-12-22 14:49:34
【问题描述】:
我的 x 轴长度为 168(7 天 * 24 小时)。我想展示 1 月 4 日、1 月 5 日……1 月 10 日),但似乎找不到如何做到这一点。
plt.plot(t, php)
plt.title('Electricity Load of heat pump at t')
fig, axes = plt.subplots(figsize=[25,7])
fig.subplots_adjust(bottom=0.2)
tindex = np.arange(0,T)
dates = pd.date_range('20210104',periods=168, freq="H")
df = pd.DataFrame({'php1': php, 'dates': dates})
df.plot(kind='line',x='dates', y='php1',
ax=axes, color ="red", linestyle='-',
linewidth=3, grid=True)
axes.tick_params(axis='x', labelsize=15)
axes.tick_params(axis='y', labelsize=15)
axes.get_legend().remove()
axes.set_ylabel('Power[kW]', fontsize=15)
axes.set_xlabel('Timeslot[Days] ', fontsize=15)
【问题讨论】:
-
现有的答案是否让您满意?我认为答案中的代码效果不佳。
标签: pandas dataframe matplotlib