我这里有一个数据帧,有两个唯一的时间窗口
df_mo4['time_window']
,
2018-09-26 11:30:00
到
2018-09-26 11:32:30
和
2018-09-26 11:32:30
到
2018-09-26 11:35:00
. 我想绘制两组柱状图(不是子块),其中第一个柱状图在一个时间窗口中表示单个id的平均时间、最大时间和最小时间,而下一个柱状图在另一个时间窗口中表示相同的数据,对此我该怎么办?另外,我希望标题像持续时间(时间窗口)。谢谢您!
df.plot(kind='bar')
plt.title('Duration \n {}'.format(df['time_window']))
plt.ylabel('Time (s)')
plt.xlabel('ID')
plt.legend(['Mean Time (s)', 'Minimum Time (s)', 'Maximum Time (s)'], loc='upper right')
plt.xticks(np.arange(len(df['ID'])), df['ID'], fontsize=5)
plt.show()
样本数据:
ID time_window mean_time min_time max_time
0 8027 2018-09-26 11:30:00 to 2018-09-26 11:32:30 0.101679 0.056412 0.340988
1 8027 2018-09-26 11:32:30 to 2018-09-26 11:35:00 0.090957 0.052196 0.323442
2 8028 2018-09-26 11:30:00 to 2018-09-26 11:32:30 0.199167 0.076872 0.614797
3 8028 2018-09-26 11:32:30 to 2018-09-26 11:35:00 0.239885 0.062660 0.590710
4 8029 2018-09-26 11:30:00 to 2018-09-26 11:32:30 0.243241 0.098516 0.5713
5 8030 2018-09-26 11:30:00 to 2018-09-26 11:32:30 0.083064 0.055656 0.27892
6 8031 2018-09-26 11:32:30 to 2018-09-26 11:35:00 0.134786 0.058290 0.51279