Dave.M.Tung | 8 Feb 21:04
Picon
Favicon

trying to Copy plot from one MplWidget canvas to another

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.tung-ShLqkCeKS0lBDgjK7y7TUQ@public.gmane.org

------------------------------------------------------------------------------
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@...
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Gmane