May-08-2019, 12:04 PM
I'm working on a plot of energy consumption versus month over a period of years.
I would like to add the dates as ticks on the x-axis, yet this gets very tight. The command
import matplotlib.pyplot as pat kwh=[88736,92100,95420,98161,100326,...,327384] yearmonthday=['2003-01-01','2003-02-01','2003-03-01','2003-04-01',...,'2015-06-01'] plt.plot(range(len(kwh)),kwh) plt.xticks(range(len(yearmonthday)),yearmonthday) plt.title('Energy consumption 2003-2015') plt.ylabel('Kilowatthour') plt.figure(figsize=(10,6)) plt.savefig('Plotx.jpg') plt.show()The current output of the plot looks something like this.
I would like to add the dates as ticks on the x-axis, yet this gets very tight. The command
plt.figure(figsize=(10,6))
doesn't really seem to work, since whenever I change it the saved figure is a blank one.