2

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. enter image description here

0

2 Answers 2

2

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()
Sign up to request clarification or add additional context in comments.

Comments

2

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. Output plot

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.