Demon
Demon

Reputation: 55

change x-axis values in plt.plot()

I have the following plot: time characteristic

Code is following:

pointdat=tracesM[458,20*250:(50)*250]
plt.plot(pointdat)
plt.show()

Where pointdat contains 7500 values (time samples) for a particular point (458 in my case). 7500 is for 30 seconds. So each second should have 250 values. I'd love to see my x-axis in seconds (from 0 till 30) and scaled in needed way.

Tried:

pointdat=tracesM[458,20*250:(50)*250]
plt.xticks(np.arange(0, 7501, 250)/250)
plt.plot(pointdat)
plt.show()

The result was: xticks was added

Any help is welcome.

Upvotes: 1

Views: 1248

Answers (1)

Abhishek Verma
Abhishek Verma

Reputation: 1729

You need to use the xticks function of matplotlib.pyplot.

pointdat=tracesM[458,20*250:(50)*250]
plt.plot(pointdat)

plt.xticks(np.arange(0, 7501, 250)/250)

plt.show()

Upvotes: 1

Related Questions