I'm back with more python problems!
I was trying to get date, high and low of a temperature from sitka weather in 2014.csv
The dates start from 2014-1-1 and end in 2014-12-22
That code shows me the graph i attached below.
Problem is the ticks or step size of the date is by 2, i was trying to change it to day-month-year with autofmt_xdate but all i got was Year and month.
I suppose the code misinterpret the month and or the day in 2014-1-1 in weather_history-2014.csv.
I have tried xlim but cant really do it with datetime.date(2014,-1,-1) it shows me
plt.xlim([datetime.date(2014-1-1), datetime.date(2014-12-22)])
TypeError: descriptor 'date' for 'datetime.datetime' objects doesn't apply to a 'int' object
long story short, how to change 2014-01 to 01-January-2014?
Edit:
Solved by using the matplotlib.dates to format the x-labels
here is the code
myFmt = mdates.DateFormatter('%Y-%b-%d')
plt.gca().xaxis.set_major_formatter(myFmt)
The ticks or step size of the X might still be by 2, but for now im satisfied.
Edit:
add this to set x labels by month. MonthLocator for every month, YearLocator for every year
plt.gca().xaxis.set_major_locator(mdates.MonthLocator())