I would like to plot vertical lines when each new part is created on top of its features like 'Aload' or 'execution'. So I have a column called 'new_part' that indicates if a new part is created and I use it to extract the Timestamp of each new part (when new_part ==1).
parts_time = fn_04_num[fn_04_num['new_part'] == 1]['Timestamp']
parts_time = pd.to_datetime(parts_time, format="%Y-%m-%d %H:%M:%S")
The following plots with no problems
fig, ax1 = plt.subplots()
color = 'tab:red'
ax1.set_xlabel('Time')
ax1.set_ylabel('Aload', color=color)
ax1.plot(fn_04_num['Timestamp'], fn_04_num['Aload'], color=color)
ax1.tick_params(axis='y', labelcolor=color)
# instantiate a second axes that shares the same x-axis
ax2 = ax1.twinx()
color = 'tab:blue'
ax2.set_ylabel('Status',
color=color)
ax2.hlines(y=fn_04_num['execution'],
xmin=fn_04_num['Timestamp'],
xmax=fn_04_num['Timestamp2'],
color=color)
ax2.tick_params(axis='y',
labelcolor=color)
but as soon as I add this loop to get the vertical lines, I get this error
ax3 = ax1.twinx()
for time in parts_time:
color = 'tab:black'
ax3.axvline(x=time)
# Right y-label is slightly clipped
fig.tight_layout()
plt.show()
TypeError: '<' not supported between instances of 'Timestamp' and 'numpy.float64'
I verified the types of my data (Timestamp is in the same format as part_time) so I really don't understand what i'm doing wrong.
Thanks for the help !