Hi i tried to shade the area between two point in time. i.e. 13:00 to 14:00 but keep getting a. ConversionError: Failed to convert value(s) to axis units: ['13,00', '14,00']
for date in dates:
data = df[df['TradeTimeUtc'].dt.date == date]
fig, ax1 = plt.subplots()
# plot spread on primary axis
ax1.plot(data['TradeTimeUtc'], data['spread'], color='blue')
ax1.set_xlabel('TradeTimeUtc')
ax1.set_ylabel('spread', color='blue')
ax1.tick_params('y', colors='blue')
# add a vertical shaded region to highlight the time between 13:00 to 14:00 and this is where the problem is
ax1.axvspan("12:00","13:00", alpha=0.2, color='gray')
# create a secondary axis for Volume
ax2 = ax1.twinx()
# plot Volume on secondary axis as a bar chart
ax2.bar(data['TradeTimeUtc'], data['acc_vol'], width = 0.0003, color='red', alpha=0.1)
ax2.set_ylabel('Volume', color='red')
ax2.tick_params('y', colors='red')
# set plot title
ax1.set_title(f'Spread and Volume on {date}')
# adjust layout
fig.tight_layout()
# show plot
plt.show()
for some reason it is not picking up the time i wanted to shade, any advice welcome, thanks