Different precision on matplotlib axis
问题 My teacher said that in a graph I must label the axis like 0, 0.25, 0.5 not 0.00,0.25,0.50,... . I know how to label it like 0.00,0.25,0.50 ( plt.yticks(np.arange(-1.5,1.5,.25)) ), however, I don't know how to plot the ticklabels with different precision. I've tried to do it like plt.yticks(np.arange(-2,2,1)) plt.yticks(np.arange(-2.25,2.25,1)) plt.yticks(np.arange(-1.5,2.5,1)) without avail. 回答1: This was already answered, for example here Matplotlib: Specify format of floats for tick lables