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 are getting
> > updated. ?You can suppress this with
> >
> > ax.set_autoscale_on(False)
> > ax.plot(overlay_markers)
> > fig.canvas.draw()
>
> Thank you, that's much easier than the animation option, which would
> be more than I need to do.
>
> Che
>
>
>
> ------------------------------
>
> Message: 3
> Date: Tue, 16 Feb 2010 11:15:51 -0800 (PST)
> From: duckman <tduck...@crowellsystems.com>
> Subject: [Matplotlib-users] Color in table help please! I have already
> searched previous posts
> To: matplotlib-users@lists.sourceforge.net
> Message-ID: <27613553.p...@talk.nabble.com>
> Content-Type: text/plain; charset=us-ascii
>
>
> I am trying to make the table at the bottom and the lines the same color.
> I
> took the code from one of the online examples and modified it to do most of
> what I want but cannot get the color in the table working properly! Can
> someone please help? Thank you
>
> #!/usr/bin/env python
> import matplotlib
> from pylab import *
> from matplotlib.colors import colorConverter
>
> color3=(1,0,0)
> axes([0.2, 0.2, 0.7, 0.6]) # leave room below the axes for the table
>
> data = [[
> 100.00,349.75,171.44,625.53,134635.8,248978.4,160392.1,179662.4,123550.5],
> [
>
> 235998.8,99972.15,242081.6,84912.13,243705.3,247201.2,203676.4,90139.60,113332.5],
> [
>
> 202610.0,127785.3,182007.1,175678.0,154024.1,188675.2,166227.0,94719.93,160227.7],
> [
>
> 31699.09,30586.87,30587.58,33440.05,32209.72,34223.97,28250.25,32070.29,19095.30],
> [
>
> 84414.35,21884.88,49538.22,49200.55,42394.29,66676.73,57740.81,73549.68,48402.48],
> [ 0.0,0.0,0.0,0.0,023529.88,19822.02,35243.35,34349.67,19382.45]]
>
> title('Title')
> colLabels = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep')
> rowLabels = ['Dr %d' % x for x in (1, 2, 3, 7, 8, 10)]
>
> linecolor = ('blue','red','green','black','yellow','cyan','magenta')
>
> rows = len(data)
>
> ind = arange(len(colLabels)) # the x locations for the groups
> cellText = []
> yoff = array([0.0] * len(colLabels)) # the bottom values for stacked bar
> chart
> for row in xrange(rows):
> plot(arange(0,9), data[row],color=linecolor[row])
> yoff = data[row]
> cellText.append(['%1.2f' % (x) for x in yoff])
> # Add a table at the bottom of the axes
>
> #title([color3])
> the_table = table(cellText=cellText,
> rowLabels=rowLabels, rowColours=[color3]*16,
> colLabels=colLabels,
> loc='bottom')
> vals = arange(0, 350000, 25000)
> yticks(vals, ['%d' % val for val in vals])
> xticks([])
> savefig("tony.png",dpi=(1024/8))
>
> --
> View this message in context:
> http://old.nabble.com/Color-in-table-help-please%21--I-have-already-searched-previous-posts-tp27613553p27613553.html
> Sent from the matplotlib - users mailing list archive at Nabble.com.
>
>
>
>
> ------------------------------
>
> Message: 4
> Date: Tue, 16 Feb 2010 22:05:30 +0100
> From: Ernest Adrogu? <eadro...@gmx.net>
> Subject: Re: [Matplotlib-users] DateFormatter + Latex issue
> To: matplotlib-users@lists.sourceforge.net
> Message-ID: <20100216210530.ga30...@doriath.local>
> Content-Type: text/plain; charset=us-ascii
>
> 16/02/10 @ 09:03 (-0500), thus spake Filipe Pires Alvarenga Fernandes:
> > Thanks Ernest, I had no idea that the DateFormatter was going to be
> treated
> > as latex as well.
>
> Yes, all strings are processed by LaTeX.
>
> >
> > However, escaping the \ with another \ did not worked.
> > I tried:
> >
> > majorF = DateFormatter("\\n \\n %b")
> >
> > How should I escape the \n ?
>
> In theory, "\\n \\n %b" or r"\n \n %b", however only the former
> seems to work in my computer.
>
> There's another problem: \n is not a valid LaTeX command.
> I tried with \\ and with \newline but neither appear to work.
> \vspace{10pts} does insert whitespace, however I am not sure if
> it's the proper way of doing it...
>
> Bye.
>
> >
> > > majorF = DateFormatter("\n \n %b") # problem
> > > ^^ ^^
> > > A common mistake.
> > > You forgot to escape the "\" characters.
> > >
> > > Bye.
> > >
> > > Ernest
> > >
>
> >
> ------------------------------------------------------------------------------
> > 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
>
>
>
>
> ------------------------------
>
> Message: 5
> Date: Tue, 16 Feb 2010 13:14:45 -0800
> From: Wayne Watson <sierra_mtnv...@sbcglobal.net>
> Subject: Re: [Matplotlib-users] Where Do I Report MPL Guide Issues?
> To: Philipp Bender <li...@rootiniert.de>
> Cc: matplotlib-users@lists.sourceforge.net
> Message-ID: <4b7b0ac5.2000...@sbcglobal.net>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Good. Thanks. Did I do the right thing by posting here? Is it the case
> that all parts of the document are contributions?
>
> On 2/15/2010 11:02 PM, Philipp Bender wrote:
> > When I come back tonight I will try to fix the errors for you.
> >
> >
> ------------------------------------------------------------------------------
> > 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
> >
> >
>
> --
> "There is nothing so annoying as to have two people
> talking when you're busy interrupting." -- Mark Twain
>
>
>
>
> ------------------------------
>
> Message: 6
> Date: Tue, 16 Feb 2010 16:20:19 -0500
> From: Filipe Pires Alvarenga Fernandes <ocef...@gmail.com>
> Subject: Re: [Matplotlib-users] DateFormatter + Latex issue
> To: matplotlib-users@lists.sourceforge.net
> Message-ID:
> <f6f7b8f11002161320p5008a274ica27d03e6c069...@mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> "\\" works for titles and label, but not for DateFormatter, but \vspace
> did
> the trick!
>
> Thanks again for the help.
>
> ps: I'm new to python, but maybe there is a way to mix Latex and unicode?
>
>
> > as latex as well.
> >
> > Yes, all strings are processed by LaTeX.
> >
> > >
> > > However, escaping the \ with another \ did not worked.
> > > I tried:
> > >
> > > majorF = DateFormatter("\\n \\n %b")
> > >
> > > How should I escape the \n ?
> >
> > In theory, "\\n \\n %b" or r"\n \n %b", however only the former
> > seems to work in my computer.
> >
> > There's another problem: \n is not a valid LaTeX command.
> > I tried with \\ and with \newline but neither appear to work.
> > \vspace{10pts} does insert whitespace, however I am not sure if
> > it's the proper way of doing it...
> >
> > Bye.
> >
> > >
> > > > majorF = DateFormatter("\n \n %b") # problem
> > > > ^^ ^^
> > > > A common mistake.
> > > > You forgot to escape the "\" characters.
> > > >
> > > > Bye.
> > > >
> > > > Ernest
> >
> > Thanks Ernest, I had no idea that the DateFormatter was going to be
> treated
> -------------- next part --------------
> An HTML attachment was scrubbed...
>
> ------------------------------
>
> Message: 7
> Date: Tue, 16 Feb 2010 16:29:59 -0500
> From: Ken Dere <kpd...@verizon.net>
> Subject: Re: [Matplotlib-users] forcing a plot to appear
> To: matplotlib-users@lists.sourceforge.net
> Message-ID: <hlf2om$8t...@ger.gmane.org>
> Content-Type: text/plain; charset="ISO-8859-1"
>
> Matthias Michler wrote:
>
> > Hi Ken,
> >
> > On Monday 15 February 2010 20:35:06 Ken Dere wrote:
> >> Hi,
> >>
> >> I am trying to develop an application that I can run inside the ipython
> >> shell. One of my methods creates a plot, asks the user to make a choice
> >> based on that plot, and then creates another plot that displays the
> >> chosen set of information.
> >>
> >> If the choices are made with a qt or wx dialogue, everything goes fine.
> >> If I try to get the choice by asking the user to type the information
> >> into the shell, neither plot appears until after the choice is made.
> >>
> >> I have tried show() and draw() but neither make any difference.
> >
> > I attached a script that allows to input a number via "raw_input" (after
> > the first figure appeared) and than opens up a second figure. I hope the
> > goes towards your needs.
> >
> > Kind regards,
> > Matthias
>
> That did the trick. I think it was problably the use of .ion() and .ioff()
> that did it but I just did the whole fix and didn't check to see what was
> what.
>
> many thanks!
>
>
> --
> K. Dere
>
>
>
>
> ------------------------------
>
> Message: 8
> Date: Tue, 16 Feb 2010 22:57:43 +0100
> From: Ernest Adrogu? <eadro...@gmx.net>
> Subject: Re: [Matplotlib-users] DateFormatter + Latex issue
> To: matplotlib-users@lists.sourceforge.net
> Message-ID: <20100216215743.ga31...@doriath.local>
> Content-Type: text/plain; charset=us-ascii
>
> 16/02/10 @ 16:20 (-0500), thus spake Filipe Pires Alvarenga Fernandes:
> > "\\" works for titles and label, but not for DateFormatter, but \vspace
> did
> > the trick!
> >
> > Thanks again for the help.
> >
> > ps: I'm new to python, but maybe there is a way to mix Latex and unicode?
>
> Yes, the inputenc package from latex lets you use unicode.
> Try adding this to your script:
> plt.rc('text.latex', preamble='\usepackage[utf]{inputenc}')
>
> Note that this setting is not officially supported, whatever
> that means :)
>
> I also like the txfonts package:
> \usepackage[varg]{txfonts}
>
> which changes the default font to Times, including the text in
> mathematical expressions. It looks great.
>
> Cheers.
>
> Ernest
>
>
>
> ------------------------------
>
>
> ------------------------------------------------------------------------------
> 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
>
>
> End of Matplotlib-users Digest, Vol 45, Issue 63
> ************************************************
>
------------------------------------------------------------------------------
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