2

I'm sure this is an easy answer, but could not find anywhere. I want the x-axis to read with the values 2000, 2001, 2002, 2003, 2004, not 2 x e**3.

import numpy as np 
import matplotlib.pyplot as plt

x = [2000, 2001, 2002, 2003, 2004]
y = [2000, 2001, 2002, 2003, 2004] 

plt.xticks(np.arange(min(x), max(x)+1, 1.0)) 
plt.plot(x,y)
plt.show()

The code returns a graph that represents the values like this. How do I change it?

enter image description here

@ avinash pandey

enter image description here

1 Answer 1

2

enter image description here You can use

plt.xticks(np.arange(min(x), max(x)+1, 1.0), x)

Try this as in your code space was already there just labels were needed... For more follow this link

Sign up to request clarification or add additional context in comments.

2 Comments

For some reason adding this line makes the x-axis disappear, although it moves some tick marks opposite the y-axis.
Picture is in the question above

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.