Reputation: 21
I want to draw an empaty graph chart. Date and time should be in Y axis and Kilometers in X axis. For reference please refer the image. I do not need blue graph line.
Upvotes: 2
Views: 1423
Reputation: 66
As similar to Amiga500, I added the x-axis date labelling and the titles for axes.
import pylab as plt
from matplotlib.ticker import MaxNLocator
x=[] #to define an empty list for x-axis data
#iterations for the string of datetime
year = str()
month = str()
t = str()
date_list = []
for i in range(0,6):
for j in range(1,13):
year = str(2004 + i)
month = str(j)
t = year + '-' + month + '-' + '1'
date_list.append(t)
ax1 = plt.subplot2grid((1,1),(0,0))
plt.ylim([0, 750])
plt.xticks(x,date_list)
ax1.xaxis.set_major_locator(MaxNLocator(len(date_list)-1))
plt.xticks(rotation=45) #make the x-axis label inclined to 45 degrees
#show the title of x and y axes
ax1.set_xlabel('Date & Time')
ax1.set_ylabel('Kilometers')
plt.show()
This is the output blank plot.
Upvotes: 2
Reputation: 1275
I don't know if this is the right way, but I kinda cheated with a subplot.
import pylab as plt
ax1 = plt.subplot2grid((1,1),(0,0))
plt.xlim([0, 100])
plt.ylim([0, 750])
plt.show()
Upvotes: 2