it's not showing in bottom right corner too. Data is coming from table in database. It plots the graph well but coordinates of x is missing on mouse hover over graph. Please help. I am using mplcursors for mouse hover.
import matplotlib.pyplot as plt
import mplcursors
from datetime import datetime
ax1 = plt.subplot(111)
time = ['2017-01-01 09:00:00.000', '2017-01-01 09:00:01.000', '2017-01-01 09:00:02.000', '2017-01-01 09:00:03.000', '2017-01-01 09:00:04.000', '2017-01-01 09:00:05.000', '2017-01-01 09:00:06.000', '2017-01-01 09:00:07.000', '2017-01-01 09:00:08.000', '2017-01-01 09:00:09.000', '2017-01-01 09:00:10.000']
lstDateTime = [str(datetime.strptime(x, '%Y-%m-%d %H:%M:%S.%f').isoformat(sep=' ', timespec='milliseconds')) for x in
time]
print(f'lstDateTime: {", ".join(lstDateTime)}')
bet = [60.01, 60.01, 62.01, 61.01, 63.79, 69.28, 63.51, 62.24, 60.53, 61.53, 60.53]
prob = [61.1, 61.2, 63.03, 62.03, 64.02, 70.28, 64.51, 63.24, 61.53, 62.53, 61.53]
plt.plot_date(lstDateTime, bet, "b-", label="bet")
plt.plot_date(lstDateTime, prob, "g-", label="porb")
plt.tick_params(axis='x', rotation=90)
# ax1.plot(lstDateTime, bet, "b-", label="bet")
# ax1.plot(lstDateTime, prob, "g-", label="porb")
# ax1.tick_params(axis='x', rotation=90)
mplcursors.cursor(hover=True)
plt.show()
what's bugging me is that from start I cannot see x coordinate even in bottom right corner of matplotlib card.
it's something I don't understand. x axis has list of timestamp.
'2017-01-01 11:43:07.000', '2017-01-01 11:43:23.000', '2017-01-01 11:42:45.000'
like this but it does not show up. Why and how to correct it I need to know.
Issue is somewhere here:- issue is in time conversion.
lstDateTime = [str(datetime.strptime(x, '%Y-%m-%d %H:%M:%S.%f').isoformat(sep=' ', timespec='milliseconds')) for x in time] print(f'lstDateTime: {", ".join(lstDateTime)}')
but it gives correct format issue is x coordinates stops showing.