[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 
> 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 
> Subject: Re: [Matplotlib-users] add to a canvas while preserving
>overall formatting
> To: Matplotlib Users 
> Message-ID:
>
> Content-Type: text/plain; charset=ISO-8859-1
>
> On Tue, Feb 16, 2010 at 12:37 PM, John Hunter  wrote:
> > On Tue, Feb 16, 2010 at 11:14 AM, C M  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 are getting
> > updated. ?You can suppress t

[Matplotlib-users] trying to Copy plot from one MplWidget canvas to another

2010-02-08 Thread Dave . M . Tung

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