My seaborn/matplotib plot is not recognizing time as time.
temp t d
0 39.9 00:24:23 03-21-2021
1 39.9 00:28:32 03-21-2021
2 39.4 00:32:41 03-21-2021
3 39.2 00:36:48 03-21-2021
4 38.8 00:40:57 03-21-2021
.. ... ... ...
240 59.0 17:02:14 03-21-2021
241 58.5 17:06:23 03-21-2021
242 58.5 17:10:31 03-21-2021
243 58.5 17:14:40 03-21-2021
244 58.1 17:18:49 03-21-2021
I'm trying to maker my x-ticks round-up to the hour
my research has led me to believe my time data is not formatted as a in a way that matplotlib recognizes as time.
this is the area of my code that generates the plot:
#panda datafram is 'values'
g=sns.lineplot(x='t', y='temp', data=values,color="darkblue")
plt.ylim(values['temp'].min()-1, values['temp'].max()+1)
plt.xticks(rotation=90)
# compensate for axis labels getting clipped off
plt.subplots_adjust(bottom=0.15, left=0.15)
g.xaxis.set_major_formatter(mdates.DateFormatter('%H:%M:%S'))
g.xaxis.set_major_locator(mdates.HourLocator(interval = 400))
g.set(xlabel='Time', ylabel='Temperature')
#create unique filename based on time
filename= "Graph-" +str(dt.datetime.now().hour)+"-"+str(dt.datetime.now().minute)+".png"
plt.savefig(filename)
If its not clear look at my X axis in my plot, the hours are all messed up ( 17, 9, 1) if you look at my data frame the time data is obvious.
I can either save my time data in a different format or I need to reformat my time data for seaborn/matplotlib ????