Is there any way in matplotlib to keep tick locations evenly whereas keeping their values uneven so that data may squeeze some interval and may expand at another. For example following code generates sine wave with ticks [0.0,0.5,1.0,1.5,2.0]
import matplotlib.pyplot as plt
import numpy as np
t = np.arange(0.0, 2.0, 0.01)
s = 1 + np.sin(2*np.pi*t)
plt.plot(t, s)
plt.xlabel('time (s)')
plt.ylabel('voltage (mV)')
plt.title('About as simple as it gets, folks')
plt.grid(True)
ax = plt.gca()
ax.get_xaxis().get_major_formatter().set_useOffset(False)
plt.autoscale(False)
ax.xaxis.set_ticks([0.0,0.5,1.0,1.5,2.0])
plt.show()
I want to change the value 0.5 to 0.25 at ax.xaxis.set_ticks([0.0,0.5,1.0,1.5,2.0]) but keep it in the same location on the plot.