【发布时间】:2020-05-15 00:09:36
【问题描述】:
我有一个时间序列图,我想在event time 处添加一条垂直线。如果我使用此代码:
event_time = pd.to_datetime('10/12/2016 06:21:00')
ax = df_stats_t.plot(x = 't', y='t_TI_var_pwr', linestyle='none',...
color = 'black', marker = 'o')
ax1 = ax.twinx()
ax1.axvline(event_time, color='red', linestyle='-')
df_stats_t.plot(x='t',y='t_TI_var_ws',ax=ax1, linestyle='none', ...
color = 'green', marker = 'o')
它采用从event_time 开始的时间序列子集,并且不会产生垂直线。
如果我将ax1.axvline(event_time, color='red', linestyle='-') 移动到底部,我会得到我想要的图,但垂直线仍然缺失。
event_time = pd.to_datetime('10/12/2016 06:21:00')
ax = df_stats_t.plot(x = 't', y='t_TI_var_pwr', linestyle='none',...
color = 'black', marker = 'o')
ax1 = ax.twinx()
df_stats_t.plot(x='t',y='t_TI_var_ws',ax=ax1, linestyle='none',...
color = 'green', marker = 'o')
ax1.axvline(event_time, color='red', linestyle='-')
对于所有 y 值,如何在 x = event_time 处显示垂直线?
【问题讨论】:
标签: pandas python-2.7 datetime plot time-series