I am making the following plot in matplotlib, using amongst other things plt.ticklabel_format(axis='y',style='sci',scilimits=(0,3))
. This yields a y-axis as so:
Now the problem is that I want the y-axis to have ticks from [0, -2, -4, -6, -8, -12]
. I have played around with the scilimits
but to no avail.
How can one force the ticks to only have one significant figure and no trailing zeros, and be floats when required?
MWE added below:
import matplotlib.pyplot as plt
import numpy as np
t = np.arange(0.0, 10000.0, 10.)
s = np.sin(np.pi*t)*np.exp(-t*0.0001)
fig, ax = plt.subplots()
ax.tick_params(axis='both', which='major')
plt.ticklabel_format(style='sci', axis='x', scilimits=(0,3))
plt.plot(t,s)
plt.show()
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…