Copying a matplotlib canvas (or a figure, or an axes) is not easy. You
cannot just rebind it. You need to copy all the hierarchy of
underlying artists. Also the attributes of artists need to be adjusted
accordingly.
And best option in my opinion is just to create another canvas using
the code that created the original canvas.

Regards,

-JJ



On Mon, Feb 8, 2010 at 3:04 PM,  <dave.m.t...@seagate.com> wrote:
> Hey folks,
>
> my problem may be obvious, but i can't seem to copy a plot from one canvas
> to another.
>
> # I have this object where whichCanvas is an instance of MplWidget (code
> shown below)
>
> self.whichCanvas.canvas.ax.plot(xData, yData, 'bo', linewidth=1.5,
> linestyle='-')
>
>
>
>
> # I want to copy the plot and axes to another MplWidget object
>
> self.anotherCanvas.canvas
>
>
>
> I've tried:
>
> self.anotherCanvas.canvas.ax = self.whichCanvas.canvas.ax
> self.anotherCanvas.canvas.draw()
>
> and
>
> self.anotherCanvas.canvas = self.whichCanvas.canvas
> self.anotherCanvas.canvas.draw()
>
> the plot doesn't seem to copy. Does any body more familiar with matplotlib
> have any suggestions?
>
>
>
>
>
> This is the MplWidget Class
> ***************************** MplWidget *******************************
>
> from PyQt4 import QtGui
> from matplotlib.backends.backend_qt4agg \
> import FigureCanvasQTAgg as FigureCanvas
> from matplotlib.figure import Figure
>
>
>
>
> class MplCanvas(FigureCanvas):
> def __init__(self):
> self.fig = Figure()
> self.ax = self.fig.add_subplot(111)
> FigureCanvas.__init__(self, self.fig)
> FigureCanvas.setSizePolicy(self,
> QtGui.QSizePolicy.Expanding,
> QtGui.QSizePolicy.Expanding)
> FigureCanvas.updateGeometry(self)
>
>
>
>
> class MplWidget(QtGui.QWidget):
>
> def __init__(self, parent = None):
> QtGui.QWidget.__init__(self, parent)
> self.canvas = MplCanvas()
> self.vbl = QtGui.QVBoxLayout()
> self.vbl.addWidget(self.canvas)
> self.setLayout(self.vbl)
>
>
>
> Regards,
> Dave Tung
>
> cell: 925-321-6657
> office: 510-353-4770
> dave.m.t...@seagate.com
>
> ------------------------------------------------------------------------------
> The Planet: dedicated and managed hosting, cloud storage, colocation
> Stay online with enterprise data centers and the best network in the
> business
> Choose flexible plans and management services without long-term contracts
> Personal 24x7 support from experience hosting pros just a phone call away.
> http://p.sf.net/sfu/theplanet-com
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to