【发布时间】:2019-05-25 12:19:14
【问题描述】:
我相信这是关于子情节的老问题。但是,我无法找到我的答案。
问题:
是否可以让我的subplot 相同地踩x-label?
y_label = 'db_server_6a_2018_df_IL1-A'
f, ax_list = plt.subplots(12, 1, gridspec_kw = {
'height_ratios': [20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20],
'width_ratios': [30]
}, figsize=(20, 40))
for month in range(1, 12 + 1):
start_dt = datetime.datetime(2018, month, 1)
end_dt = start_dt + relativedelta(months=1)
window_df = df[(start_dt < df['Time']) & (df['Time'] <= end_dt)]
ax = ax_list[month-1]
ax.plot(window_df['Time'], window_df[y_label])
ax.set_ylabel(start_dt.strftime('%B'))
ax.set_xlabel('datetime')
f.savefig(y_label + '.png')
【问题讨论】:
标签: python matplotlib label subplot