Datetime annoyances - python matplotlib
Go to solution
Solved by DominHoes,
5 hours ago, Sauron said:Then it's possible matplotlib doesn't recognize the datetime.date format. Try using matplotlib.dates, you may have better luck.
Found the solution.
By importing matplotlib.dates, i was able to access 'mdates.Dateformatter' and use it in plt current axes or plt.gca().
Spoiler
#format plot
title="Daily high and low temperatures, - 2014"
plt.title(title, fontsize=20)
plt.xlabel('', fontsize=8)
#ax.xaxis.set_major_formatter(myFmt)
#plt.xlim([datetime.date(2014,1,1), datetime.date(2014,12,22)])
fig.autofmt_xdate()
myFmt = mdates.DateFormatter('%Y-%b-%d')
plt.gca().xaxis.set_major_formatter(myFmt)
plt.ylabel("Temperature (F)", fontsize=16)
plt.tick_params(axis='both', which='major', labelsize=16)
plt.ylim(10, 120)

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now