how to adjust x axis in matplotlib


Question

I have a graph like thisenter image description here

The data on the x axis means hours, so I want the x axis to set as 0, 24, 48, 72.....instead of the value now, which is difficult to see the data between [0,100]

fig1 = plt.figure()  
ax = fig1.add_subplot(111)
ax.set_yscale('log')
ax.plot(x,y,'b-')

According to the the first answer, I got this: enter image description here

1
2
8/24/2012 1:24:56 PM

Look at the docs :

xlocs, xlabs = plt.xticks()

put in xlocs your range, and in xlabs what you want to display.

then:

 plt.xticks(xlocs, xlabs)
4
8/24/2012 12:54:01 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon