Trouble With Aligning Two Y-axis Ticks With Matplotlib
I am attempting to align two sets of separate y-axis using python and matplotlib, and am running into behavior I don't understand. Here is my code so far: import matplotlib.pyplot
Solution 1:
The two y axes do not have the same limits: in one case you fluke the same lower value in the automatic range calculation while in the other you don't. If you define one yaxis range in terms of the other, I think you achieve what you want:
lim1 = ax1.get_ylim()
lim2 = (lim1[0]*2, lim1[1] *2)
ax2.set_ylim(lim2)
(and if you don't explicitly set the ax2 yticks then ticks will still get rendered if you move beyond the original range in interactive mode).
Post a Comment for "Trouble With Aligning Two Y-axis Ticks With Matplotlib"