twiny() in matplotlib changes the y-axis scale
问题 Plotting some data with matplotlib, it happens that inserting the ax.twiny() module changes the scale of the y axis. Before I use it: And after: I would like to avoid to insert manually the limits in the y-axis. So why does this happen, and how to fix it? 回答1: That's weird. I've tried using the twiny() option and it does not change the scale: import numpy import matplotlib.pylab as plt x = numpy.linspace(0, 4. * numpy.pi, 1000) y = numpy.cos(x) fig = plt.figure() ax1 = fig.add_subplot(1,1,1)