On Wed, Jul 11, 2012 at 12:45 PM, Joshua Koehler <jjkoehl...@gmail.com>wrote:

> Hi all,
>
> I am currently trying to have two panels each with their own figure
> instance so they can have separate plots.
>
> I can successfully update a plot if there is only one panel. As soon as I
> add a second panel, I get the following error when I try to update (replot)
> a plot (Showing last message only):
>
> File
> "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/axes.py",
> line 1374, in _sci
>     "Argument must be an image, collection, or ContourSet in this Axes")
> ValueError: Argument must be an image, collection, or ContourSet in this
> Axes
>
> I looked online first and one site suggested it was because I was using
> matplotlib.Figure instead of pylab.Figure. I switched and the problem still
> occurs. I was curious to see if this problem had to do with how I set up my
> program, not with matplotlib, so I wrote a little test program. The exact
> same problem occurs. I have attached the test program. To see that it does
> work with just one panel comment out lines 39, 41, and 49. When put back
> in, I get the above error message.
>
> Any suggestions as to how to fix this?
>
> Thanks!
>
> Josh
>
>
Josh,

Can you please post the entire traceback?  My suspicion for what is
happening is that both figures are sharing the same canvas, but I am not
exactly sure.  Anyway, when you perform a plot on one panel, you are
calling "clear()" for that figure, which may be having side-effects for the
other figure since it is attached to the same Wx object.

Actually, looking over your code again, I see a few things that may or may
not be part of the problem, but should be addressed, nevertheless.  First,
you are calling FigureCanvas and assigning it to self.canvas.  This canvas
is different from the canvas that the figure will actually use, so I am not
sure if this is being done correctly.  Second, your call to "plt.close()"
assumes that the figure you want to close is the currently active figure.
What you want to call is "plt.close(self.figure)" in order to make sure it
closes the figure you intend to close.

Ben Root
------------------------------------------------------------------------------
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