[Matplotlib-users] howto save MplWidget to png or tif file --- savefig not working

2010-02-16 Thread Dave M Tung
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)


On Tue, Feb 16, 2010 at 1:57 PM, 
matplotlib-users-requ...@lists.sourceforge.net wrote:

 Send Matplotlib-users mailing list submissions to
matplotlib-users@lists.sourceforge.net

 To subscribe or unsubscribe via the World Wide Web, visit
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
 or, via email, send a message with subject or body 'help' to
matplotlib-users-requ...@lists.sourceforge.net

 You can reach the person managing the list at
matplotlib-users-ow...@lists.sourceforge.net

 When replying, please edit your Subject line so it is more specific
 than Re: Contents of Matplotlib-users digest...


 Today's Topics:

   1. Suggestion for filtering by calendar? (David Carmean)
   2. Re: add to a canvas while preserving overall  formatting (C M)
   3. Color in table help please! I have already searched previous
  posts (duckman)
   4. Re: DateFormatter + Latex issue (Ernest Adrogu?)
   5. Re: Where Do I Report MPL Guide Issues? (Wayne Watson)
   6. Re: DateFormatter + Latex issue (Filipe Pires Alvarenga Fernandes)
   7. Re: forcing a plot to appear (Ken Dere)
   8. Re: DateFormatter + Latex issue (Ernest Adrogu?)


 --

 Message: 1
 Date: Tue, 16 Feb 2010 09:51:47 -0800
 From: David Carmean d...@halibut.com
 Subject: [Matplotlib-users] Suggestion for filtering by calendar?
 To: matplotlib-users@lists.sourceforge.net
 Message-ID: 20100216095147.k26...@halibut.com
 Content-Type: text/plain; charset=us-ascii


 I have a time-series dataset for which I need to make several plots;
 some of them will use all of the data, but others need not only to
 show just the usual business hours, but also take business holidays
 into account.  I thoght this might be sufficiently common in this
 community that somebody could easily point me to a python idiom/recipe
 they've used that I could extend to use masked arrays.

 FWIW, the idea is not that I want to skip those time periods on the
 visualizations--and thus the recipes which treat the data as
 non-timeseries and construct custom ticks are not the solution for me.
 One of the tasks will be to use a fill to shade in these working hours
 for some of the plots.  Another will be to calculate and plot running
 averages that exclude non-working hours.

 Thanks.





 --

 Message: 2
 Date: Tue, 16 Feb 2010 14:07:04 -0500
 From: C M cmpyt...@gmail.com
 Subject: Re: [Matplotlib-users] add to a canvas while preserving
overall formatting
 To: Matplotlib Users matplotlib-users@lists.sourceforge.net
 Message-ID:
cc8074371002161107w6ef0f865wdece7d0a74c61...@mail.gmail.com
 Content-Type: text/plain; charset=ISO-8859-1

 On Tue, Feb 16, 2010 at 12:37 PM, John Hunter jdh2...@gmail.com wrote:
  On Tue, Feb 16, 2010 at 11:14 AM, C M cmpyt...@gmail.com wrote:
  I have a mpl graph embedded in wxPython, and I call a function,
  customize_plot() to do a number of things to the plot: ?adjust the
  spacing around it, set the formatters, fontsizes, axis limits, set a
  grid, etc.
 
  Now I want to potentially highlight points (by adding semi-transparent
  points on top of existing ones) or annotate points with user
  interaction. ?If I do that, it seems I need to call canvas.draw().
  But when I do that, it redraws the whole canvas and ignores some of
  the formatting I laid out in customize_plot(), specifically the view
  limits, and that's not acceptable.
 
  This isn't accurate -- calling draw will not change the view limits.
  In all likelihood what is happening is that when you add you your
  overlay markers, eg by calling plot the view limits 

Re: [Matplotlib-users] howto save MplWidget to png or tif file --- savefig not working

2010-02-16 Thread John Hunter
On Tue, Feb 16, 2010 at 4:07 PM, Dave M Tung dave.m.t...@seagate.com 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
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users