python - Set scale of axis in plot using matplotlib -
i unable scale y-axis. code follows:
import matplotlib.pyplot pt import numpy np fig = pt.figure() ax = fig.add_subplot(111) sample = 20 x=np.arange(sample) y=10*np.sin(2*np.pi*x/20) pt.plot(x,y) pt.show() the y axis has scale of 5. i'm trying make 1. 
you can using set_yticks way:
import matplotlib.pyplot plt import numpy np fig = plt.figure() ax = fig.add_subplot(111) sample = 20 x=np.arange(sample) y=10*np.sin(2*np.pi*x/20) ax.plot(x,y) ax.set_yticks(np.arange(min(y), max(y)+1, 1.0)) # setting ticks ax.set_xlabel('x') ax.set_ylabel('y') fig.show() which produces image wherein y-axis has scale of 1.

Comments
Post a Comment