On Tue, Feb 16, 2010 at 4:07 PM, Dave M Tung <[email protected]> wrote:
>
> HI folks,
>
> anybody know how to save a canvas (MplWidget) to a png or tif file.
> Seems
> when I try to save the figure,
>
> whichCanvas.canvas.ax.plot(xSlice, ySlice, 'bo', linewidth=1.5,
> linestyle='-')
>
> savefig does not work for this type of object. Is there another method I
> should use that I
> missed?
> thanks
> dave
> ************************************************************ MplWidget
> Classs ************************************************
> from PyQt4 import QtGui
>
> - Ignored:
> 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)
widget.canvas.figure.savefig('somefile')
should work
------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
_______________________________________________
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users