On Thu, May 24, 2012 at 9:54 AM, Benjamin Root <firstname.lastname@example.org>
Just got bit by this and I thought I'd share to help others.
I was just quickly writing out some pyplot commands to create two subplots to compare some results. I did:
plt.subplots(1, 2, 1)
xlim = plt.xlim()
ylim = plt.ylim()
plt.subplots(1, 2, 2)
Did you see the error? I did "subplots" instead of "subplot". Since the third argument for plt.subplot is "sharex", a value of 1 or 2 appears perfectly valid to it. Meanwhile, the second call to plt.subplots() throws out my first subplot, and I also get the seemingly odd behavior of the first subplot having the correct x limits, but the default y limits (0, 1). Of course, this makes sense once you figure out the issue, but it is an extra wrinkle that can be quite confusing.
I suspect this is a very easy mistake to make. Should we perhaps test the value of sharex in subplots() and warn if it is anything but a python bool? Just a thought.