- #1
schniefen
- 178
- 4
- TL;DR Summary
- Fitting xtickslabels on plot
How could I improve the below code to fit all the xtickslabels on my plot more nicely (i.e. more spacing between the labels, higher resolution)? Thanks!
Python:
from pyplot import *
yearmonthday=['2003-01-01', '2003-02-01', '2003-03-01', ...] #len(yearmonthday) is 155
kwh = [88883, 99221, 100002, ...]
fig,ax=subplots(figsize=(9,2))
ax.plot(range(len(kwh)),kwh)
ax.set_xticks(range(len(yearmonthday)))
ax.set_xticklabels(yearmonthday, fontsize = 4,rotation=60)
ax.set_xlim(0,155,310)
fig.tight_layout()
ax.set_title('Energy consumption 2003-2015')
ax.set_ylabel('Kilowatthour')