On Thu, May 24, 2012 at 9:54 AM, Benjamin Root <ben.r...@ou.edu> wrote:

> 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)
> plt.contourf(....)
> plt.title("Contours")
> xlim = plt.xlim()
> ylim = plt.ylim()
>
> plt.subplots(1, 2, 2)
> plt.imshow(....)
> plt.title("Raw Image")
> plt.xlim(xlim)
> plt.ylim(ylim)
>
>
> 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.
>
> Cheers!
> Ben Root
>
>
+1 : I switch `subplots` and `subplot` quite frequently, so a check would
be helpful.

-Tony
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to