0

I have many y-axis values let's say 8000, these 8000 values are all necessary ,and if I plot them into a line graph, I would get 1 to 8000 in some ticks, which is too large. I want to change the 1 to 8000 into 1 to 12 without losing any y-axis values, what shall I do ?

Here is an example graph which I have already got. Imgur link: https://i.stack.imgur.com/s8ClN.jpg

pmValue_2010 =PRSA_data.iloc[1:8762,5]
year = range(1,8762) 

plt.plot(year,pmValue_2010)

plt.show()

I want to change to a graph like this

Imgur link: https://i.stack.imgur.com/59ydF.jpg as you can see, the x-axis with different formats, all I want to do is change them into a certain range and do not lose any value of the y-axis

Sorry, not enough rep to post image here.

1 Answers1

0

You could put something like this before plt.show():

locs, _ = plt.xticks()
plt.xticks(locs[::500])

This gets a list of the current x-tick/label locations and sets them to every 500 in the list.

Ari Cooper-Davis
  • 3,374
  • 3
  • 26
  • 43