SourceForge logo
SourceForge logo
Menu

matplotlib-users — Discussion related to using matplotlib

You can subscribe to this list here.

2003 Jan
Feb
Mar
Apr
May
(3)
Jun
Jul
Aug
(12)
Sep
(12)
Oct
(56)
Nov
(65)
Dec
(37)
2004 Jan
(59)
Feb
(78)
Mar
(153)
Apr
(205)
May
(184)
Jun
(123)
Jul
(171)
Aug
(156)
Sep
(190)
Oct
(120)
Nov
(154)
Dec
(223)
2005 Jan
(184)
Feb
(267)
Mar
(214)
Apr
(286)
May
(320)
Jun
(299)
Jul
(348)
Aug
(283)
Sep
(355)
Oct
(293)
Nov
(232)
Dec
(203)
2006 Jan
(352)
Feb
(358)
Mar
(403)
Apr
(313)
May
(165)
Jun
(281)
Jul
(316)
Aug
(228)
Sep
(279)
Oct
(243)
Nov
(315)
Dec
(345)
2007 Jan
(260)
Feb
(323)
Mar
(340)
Apr
(319)
May
(290)
Jun
(296)
Jul
(221)
Aug
(292)
Sep
(242)
Oct
(248)
Nov
(242)
Dec
(332)
2008 Jan
(312)
Feb
(359)
Mar
(454)
Apr
(287)
May
(340)
Jun
(450)
Jul
(403)
Aug
(324)
Sep
(349)
Oct
(385)
Nov
(363)
Dec
(437)
2009 Jan
(500)
Feb
(301)
Mar
(409)
Apr
(486)
May
(545)
Jun
(391)
Jul
(518)
Aug
(497)
Sep
(492)
Oct
(429)
Nov
(357)
Dec
(310)
2010 Jan
(371)
Feb
(657)
Mar
(519)
Apr
(432)
May
(312)
Jun
(416)
Jul
(477)
Aug
(386)
Sep
(419)
Oct
(435)
Nov
(320)
Dec
(202)
2011 Jan
(321)
Feb
(413)
Mar
(299)
Apr
(215)
May
(284)
Jun
(203)
Jul
(207)
Aug
(314)
Sep
(321)
Oct
(259)
Nov
(347)
Dec
(209)
2012 Jan
(322)
Feb
(414)
Mar
(377)
Apr
(179)
May
(173)
Jun
(234)
Jul
(295)
Aug
(239)
Sep
(276)
Oct
(355)
Nov
(144)
Dec
(108)
2013 Jan
(170)
Feb
(89)
Mar
(204)
Apr
(133)
May
(142)
Jun
(89)
Jul
(160)
Aug
(180)
Sep
(69)
Oct
(136)
Nov
(83)
Dec
(32)
2014 Jan
(71)
Feb
(90)
Mar
(161)
Apr
(117)
May
(78)
Jun
(94)
Jul
(60)
Aug
(83)
Sep
(102)
Oct
(132)
Nov
(154)
Dec
(96)
2015 Jan
(45)
Feb
(138)
Mar
(176)
Apr
(132)
May
(119)
Jun
(124)
Jul
(77)
Aug
(31)
Sep
(34)
Oct
(22)
Nov
(23)
Dec
(9)
2016 Jan
(26)
Feb
(17)
Mar
(10)
Apr
(8)
May
(4)
Jun
(8)
Jul
(6)
Aug
(5)
Sep
(9)
Oct
(4)
Nov
Dec
2017 Jan
(5)
Feb
(7)
Mar
(1)
Apr
(5)
May
Jun
(3)
Jul
(6)
Aug
(1)
Sep
Oct
(2)
Nov
(1)
Dec
2018 Jan
Feb
Mar
Apr
(1)
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2020 Jan
Feb
Mar
Apr
May
(1)
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2025 Jan
(1)
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
S M T W T F S

1
(20)
2
(16)
3
(9)
4
(12)
5
(14)
6
(22)
7
(17)
8
(33)
9
(26)
10
(32)
11
(47)
12
(26)
13
(7)
14
(24)
15
(44)
16
(42)
17
(22)
18
(31)
19
(8)
20
(4)
21
(15)
22
(27)
23
(41)
24
(33)
25
(31)
26
(24)
27
(10)
28
(20)






Showing results of 41

1 2 > >> (Page 1 of 2)
From: Jae-Joon L. <lee...@gm...> - 2010年02月16日 23:17:36
On Tue, Feb 16, 2010 at 5:25 PM, Filipe Pires Alvarenga Fernandes
<oc...@gm...> wrote:
> I haven't notice the "s" before when using "pts", but what is really
> strange is that "pt" does not work!
>
As I said, it is not supposed to work, because of some technical
reason. When there is a single line of text, it is hardly possible to
get to know the original baseline of the text.
By the way, the original problem that "\n\n %b" didn't work seems like
a actual bug (it is supposed to work without escaping '\n'). This
should now be fixed in the svn (r8135 in maint. branch and r8136 in
HEAD) . Still, it is recommended to adjust the pad of the ticklabels
instead of fiddling with newlines and etc.
Regards,
-JJ
From: John H. <jd...@gm...> - 2010年02月16日 22:42:24
On Tue, Feb 16, 2010 at 4:07 PM, Dave M Tung <dav...@se...> 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
From: Filipe P. A. F. <oc...@gm...> - 2010年02月16日 22:26:11
JJ:
Wonderful, simple and much less messy and Latex+unicode. Although, now I'm
fascinated by the Latex possibilities!
Ernest:
 I haven't notice the "s" before when using "pts", but what is really
strange is that "pt" does not work!
Thank you all again, Filipe
From: Ernest A. <ead...@gm...> - 2010年02月16日 22:20:33
Hi,
16/02/10 @ 17:01 (-0500), thus spake Jae-Joon Lee:
> On Tue, Feb 16, 2010 at 4:05 PM, Ernest Adrogué <ead...@gm...> wrote:
> > \vspace{10pts} does insert whitespace, however I am not sure if
> > it's the proper way of doing it...
> >
> 
> Can you (or someone else) confirm this? I don't think "pts" is a
> proper tex unit and it should be \vspace{10pt}. Maybe this is a typo
> in the email. I'm asking this because it does not work for me, and I
> don't think it is supposed to work (but I may be wrong).
You're right!
\vspace{10pts} adds space (seems about 10 points) but it also
prints a "s" before the space, which I didn't see before.
Now, \vspace{10pt} doesn't work for me... it simply does nothing.
Bye.
> Regards,
> 
> -JJ
From: Dave M T. <dav...@se...> - 2010年02月16日 22:07:47
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, <
mat...@li...> wrote:
> Send Matplotlib-users mailing list submissions to
> mat...@li...
>
> 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
> mat...@li...
>
> You can reach the person managing the list at
> mat...@li...
>
> 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: 2010年2月16日 09:51:47 -0800
> From: David Carmean <dl...@ha...>
> Subject: [Matplotlib-users] Suggestion for filtering by calendar?
> To: mat...@li...
> Message-ID: <201...@ha...>
> 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: 2010年2月16日 14:07:04 -0500
> From: C M <cmp...@gm...>
> Subject: Re: [Matplotlib-users] add to a canvas while preserving
> overall formatting
> To: Matplotlib Users <mat...@li...>
> Message-ID:
> <cc8...@ma...>
> Content-Type: text/plain; charset=ISO-8859-1
>
> On Tue, Feb 16, 2010 at 12:37 PM, John Hunter <jd...@gm...> wrote:
> > On Tue, Feb 16, 2010 at 11:14 AM, C M <cmp...@gm...> 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: 2010年2月16日 11:15:51 -0800 (PST)
> From: duckman <tdu...@cr...>
> Subject: [Matplotlib-users] Color in table help please! I have already
> searched previous posts
> To: mat...@li...
> Message-ID: <276...@ta...>
> 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: 2010年2月16日 22:05:30 +0100
> From: Ernest Adrogu? <ead...@gm...>
> Subject: Re: [Matplotlib-users] DateFormatter + Latex issue
> To: mat...@li...
> Message-ID: <20100216210530.GA30924@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
> > Mat...@li...
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
>
>
> ------------------------------
>
> Message: 5
> Date: 2010年2月16日 13:14:45 -0800
> From: Wayne Watson <sie...@sb...>
> Subject: Re: [Matplotlib-users] Where Do I Report MPL Guide Issues?
> To: Philipp Bender <li...@ro...>
> Cc: mat...@li...
> Message-ID: <4B7...@sb...>
> 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
> > Mat...@li...
> > 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: 2010年2月16日 16:20:19 -0500
> From: Filipe Pires Alvarenga Fernandes <oc...@gm...>
> Subject: Re: [Matplotlib-users] DateFormatter + Latex issue
> To: mat...@li...
> Message-ID:
> <f6f...@ma...>
> 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: 2010年2月16日 16:29:59 -0500
> From: Ken Dere <kp...@ve...>
> Subject: Re: [Matplotlib-users] forcing a plot to appear
> To: mat...@li...
> Message-ID: <hlf2om8ドルtc1ドル...@ge...>
> 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: 2010年2月16日 22:57:43 +0100
> From: Ernest Adrogu? <ead...@gm...>
> Subject: Re: [Matplotlib-users] DateFormatter + Latex issue
> To: mat...@li...
> Message-ID: <20100216215743.GA31425@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
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
> End of Matplotlib-users Digest, Vol 45, Issue 63
> ************************************************
>
From: Jae-Joon L. <lee...@gm...> - 2010年02月16日 22:03:22
If what you want is to have more padding for the major tick labels, I
recommend you to use
rcParams['xtick.major.pad'] = 20
If you don't like to change the global setting, you may set the
ticklabel padding for an specific axis. Try
for tck in ax.xaxis.get_major_ticks():
 tck.set_pad(20)
 tck.label1 = tck._get_text1()
Regards,
-JJ
On Tue, Feb 16, 2010 at 4:20 PM, Filipe Pires Alvarenga Fernandes
<oc...@gm...> wrote:
> "\\" 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
>
> ------------------------------------------------------------------------------
> 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
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
From: <PH...@Ge...> - 2010年02月16日 22:02:44
> -----Original Message-----
> From: Ernest Adrogué [mailto:ead...@gm...]
> Sent: Tuesday, February 16, 2010 1:58 PM
> To: mat...@li...
> Subject: Re: [Matplotlib-users] DateFormatter + Latex issue
> 
> 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.
Good tip. I also like \usapackage{fourier} to get the utopia fonts, which are particularly useful since I'm always plotting concentrations and having a upright mu ($\othermu$) is really nice.
-paul h.
From: Jae-Joon L. <lee...@gm...> - 2010年02月16日 22:01:47
On Tue, Feb 16, 2010 at 4:05 PM, Ernest Adrogué <ead...@gm...> wrote:
> \vspace{10pts} does insert whitespace, however I am not sure if
> it's the proper way of doing it...
>
Can you (or someone else) confirm this? I don't think "pts" is a
proper tex unit and it should be \vspace{10pt}. Maybe this is a typo
in the email. I'm asking this because it does not work for me, and I
don't think it is supposed to work (but I may be wrong).
Regards,
-JJ
From: Ernest A. <ead...@gm...> - 2010年02月16日 21:57:17
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
From: Ken D. <kp...@ve...> - 2010年02月16日 21:30:53
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
From: Filipe P. A. F. <oc...@gm...> - 2010年02月16日 21:20:26
"\\" 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
From: Wayne W. <sie...@sb...> - 2010年02月16日 21:14:55
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
> Mat...@li...
> 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
From: Ernest A. <ead...@gm...> - 2010年02月16日 21:05:06
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
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: duckman <tdu...@cr...> - 2010年02月16日 19:15:58
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.
From: C M <cmp...@gm...> - 2010年02月16日 19:07:14
On Tue, Feb 16, 2010 at 12:37 PM, John Hunter <jd...@gm...> wrote:
> On Tue, Feb 16, 2010 at 11:14 AM, C M <cmp...@gm...> 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
From: David C. <dl...@ha...> - 2010年02月16日 17:51:56
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.
From: John H. <jd...@gm...> - 2010年02月16日 17:37:51
On Tue, Feb 16, 2010 at 11:14 AM, C M <cmp...@gm...> 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()
> I want it to simply add the new points without changing any of the
> features of the plot. Is there a way to do that? In Googling for
> hints, I found this point from JDH from almost two years ago, which I
> think is applicable to my need:
>
>> If you call fig.canvas.draw, everything will be updated. If you want
>> to selectively draw certain artists, you can use the animated property
>> w/ background copy/restore and the draw_artist method as described at
>
>> http://www.scipy.org/Cookbook/Matplotlib/Animations
>
> Is this still the case in the current version of matplotlib? Or is
> there a newer way to do it now?
Yes, this is still accurate, and can be use for more efficient
updating, but it is unrelated to the problem with the view limits you
described.
JDH
From: John H. <jd...@gm...> - 2010年02月16日 17:15:46
On Tue, Feb 16, 2010 at 10:54 AM, John Jameson
<jja...@al...> wrote:
> Hi John,
>
> Thanks for your help on the animation with patches, and now
> I'm trying to do the same idea for matplotlib.patches.Polygon
> ala your method for a circle patch:
>
>  initialize:
>    xy =[[x0,y0],[x1,y1],[x2,y2]]
>   poly = Polygon( xy, animated=True,lw=2,fill=False )
>    add_patch(poly)
>                .
>                .
>  in the loop:
>    poly.set_xy = xy_new
>    poly.update_transorm() (no such routine)
>
>
> The set_xy seems to work (at least no errors), but I don't see how
> to "update the transform" as for the circle.
Two problems here :
* There is no polygon attribute "set_xy"; it is a method, so you need
to call it like "poly.set_xy(xy_new)". In general this is True for
all matplotlib set_* methods. There is also an "xy" attribute which
you can access like "poly.xy = xy_new". These two approaches do the
same thing
* The _update_transforms call was a hack I did on CirclePolygon to
work around a broken method. it is not a method of Polygon or Patch
which is why you are not finding it. For normal usage, the methods
that start with underscores are not meant to be called or used at the
user level, but because there was breakage in the CirclePolygon set_xy
method, I had to hack around it in the example I posted for you. For
Polygon, simply setting the xy attribute should be sufficient.
JDH
From: C M <cmp...@gm...> - 2010年02月16日 17:15:01
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.
I want it to simply add the new points without changing any of the
features of the plot. Is there a way to do that? In Googling for
hints, I found this point from JDH from almost two years ago, which I
think is applicable to my need:
> If you call fig.canvas.draw, everything will be updated. If you want
> to selectively draw certain artists, you can use the animated property
> w/ background copy/restore and the draw_artist method as described at
> http://www.scipy.org/Cookbook/Matplotlib/Animations
Is this still the case in the current version of matplotlib? Or is
there a newer way to do it now?
Thank you for any suggestions,
Che
From: Brendan B. <bre...@br...> - 2010年02月16日 17:13:57
Jae-Joon Lee wrote:
>> I have added a bbox support for "restore_region", but I'm afraid
>> that this feature is not well tested. And I guess what you find
>> is, unfortunately, a bug. While I'll try to push the changes to
>> the svn tomorrow, you may try to monkey-patch with following
>> code.
<snip>
	Thanks a lot, this seems to basically work. For some reason the
bboxes are still restored at slightly the wrong place --- I have to
adjust them by one pixel in the y direction, but this is doable.
>> However, while matplotlib does support some animation, I think
>> you 'd better turn to another tool if you need an efficiency,
	Maybe so. What tool would you recommend for animated plots?
Best wishes,
-- Brendan Barnwell "Do not follow where the path may lead. Go,
instead, where there is no path, and leave a trail." --author unknown
From: Jeff W. <js...@fa...> - 2010年02月16日 17:08:03
T J wrote:
> Hi,
>
> I'm trying to grid irregularly spaced data, such that the convex hull
> of the data is not rectangular. Specifically, all my data lies in an
> equilateral triangle inside the unit circle. I found:
>
> http://www.scipy.org/Cookbook/Matplotlib/Gridding_irregularly_spaced_data
>
> and tried the suggested technique. For my grid, I made a square of
> the min and max of my data. However, it had problems:
>
> ...
> File "/home/guest/.local/lib/python2.6/site-packages/matplotlib/delaunay/triangulate.py",
> line 125, in _compute_convex_hull
> hull.append(edges.pop(hull[-1]))
> KeyError: 0
>
>
> Should I expect matplotlib.mlab.griddata to work with a dataset like
> this? I know that I can use hexbin, but it'd be really nice to see
> contours explicitly.
> 
We have the natgrid toolkit for just this reason - it's slower than the 
default, and has a more restrictive license, but it often succeeds when 
the default algorithm fails. This is discussed at the end of that wiki 
page. Let us know if the natgrid toolkit also fails.
-Jeff
-- 
Jeffrey S. Whitaker Phone : (303)497-6313
Meteorologist FAX : (303)497-6449
NOAA/OAR/PSD R/PSD1 Email : Jef...@no...
325 Broadway Office : Skaggs Research Cntr 1D-113
Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg
From: John J. <jja...@al...> - 2010年02月16日 16:54:40
Hi John,
Thanks for your help on the animation with patches, and now
I'm trying to do the same idea for matplotlib.patches.Polygon 
ala your method for a circle patch:
 initialize:
	xy =[[x0,y0],[x1,y1],[x2,y2]]
 poly = Polygon( xy, animated=True,lw=2,fill=False )
	add_patch(poly)
				.
				.
 in the loop:
	poly.set_xy = xy_new
	poly.update_transorm() (no such routine)	
 
The set_xy seems to work (at least no errors), but I don't see how 
to "update the transform" as for the circle.
here I am looking at:
http://matplotlib.sourceforge.net/api/artist_api.html?highlight=polygon#matp
lotlib.patches.Polygon 
thanks,
john
-----Original Message-----
From: John Hunter [mailto:jd...@gm...] 
Sent: Sunday, February 14, 2010 7:39 PM
To: John Jameson
Cc: mat...@li...; Michael Droettboom
Subject: Re: [Matplotlib-users] memory leak for GTKAgg animation
On Sat, Feb 13, 2010 at 2:53 PM, John Jameson <jja...@al...>
wrote:
> HI,
> I find the very basic animation below has a memory leak (my pagefile usage
> number keeps growing in the Windows XP Windows Task Manager Performance
> graph).I don't see this with the "animation_blit_gtk.py" example on:
>
> http://matplotlib.sourceforge.net/examples/index.html
>
> (which I used as a starting point for this). In "animation_blit_gtk.py"
the
> set_ydata() routine is used to update the line for the animation and this
> does not leak. But if you call plot again with the new y_data (instead of
> using set_ydata), this leaks too. Anyone have an idea on how to stop the
> leak?
This isn't a memory leak. The problem is that you keep adding new
patches to the axes when you want just one with different data. Eg,
in your loop, run this code, and you will see that the number of
patches is growing:
 x_cir = 1.0 + 0.003*update_line.cnt
 cir = CirclePolygon((x_cir, 1), 0.3, animated=True, \
 resolution=12, lw=2 )
 ax.add_patch(cir)
 ax.draw_artist(cir)
 print 'num patches=%d, mem usage=%d'%(
 len(ax.patches), cbook.report_memory(update_line.cnt))
 canvas.blit(ax.bbox)
You should add just one patch and then manipulate the data. In this
case, you are using a CirclePolygon which derives from RegularPolygon
and so you can update the "xy" property
 
http://matplotlib.sourceforge.net/api/artist_api.html#matplotlib.patches.Reg
ularPolygon
But on testing this it looks like there is a bug in that the set_xy
property setter is ignored. I worked around this in the func below by
setting the private variable directly, but this looks like a bug we
need to fix (Michael, shouldn't we respect the xy passed in in
patches.RegularPolygon._set_xy ?). In the meantime, the following
workaround should work for you w/o leaking....
def update_line():
 global x, y
 print update_line.cnt
 if update_line.background is None:
 update_line.background = canvas.copy_from_bbox(ax.bbox)
 canvas.restore_region(update_line.background)
 x_cir = 1.0 + 0.003*update_line.cnt
 if update_line.cir is None:
 cir = CirclePolygon((x_cir, 1), 0.3, animated=True, \
 resolution=12, lw=2 )
 ax.add_patch(cir)
 update_line.cir = cir
 else:
 update_line.cir._xy = x_cir, 1
 update_line.cir._update_transform()
 ax.draw_artist(update_line.cir)
 print 'num patches=%d, xy=%s, mem usage=%d'%(
 len(ax.patches), update_line.cir.xy,
cbook.report_memory(update_line.cnt))
 canvas.blit(ax.bbox)
 if update_line.direction == 0:
 update_line.cnt += 1
 if update_line.cnt > 500:
 update_line.direction = 1
 else:
 update_line.cnt -= 1
 if update_line.cnt < 100:
 update_line.direction = 0
 return update_line.cnt<100
update_line.cnt = 0
update_line.direction = 0
update_line.background = None
update_line.cir = None
From: Robert K. <rob...@gm...> - 2010年02月16日 16:40:27
On 2010年02月16日 00:40 AM, T J wrote:
> Hi,
>
> I'm trying to grid irregularly spaced data, such that the convex hull
> of the data is not rectangular. Specifically, all my data lies in an
> equilateral triangle inside the unit circle. I found:
>
> http://www.scipy.org/Cookbook/Matplotlib/Gridding_irregularly_spaced_data
>
> and tried the suggested technique. For my grid, I made a square of
> the min and max of my data. However, it had problems:
>
> ...
> File "/home/guest/.local/lib/python2.6/site-packages/matplotlib/delaunay/triangulate.py",
> line 125, in _compute_convex_hull
> hull.append(edges.pop(hull[-1]))
> KeyError: 0
>
>
> Should I expect matplotlib.mlab.griddata to work with a dataset like
> this? I know that I can use hexbin, but it'd be really nice to see
> contours explicitly.
It's not a problem with your points lying inside a triangle. There is some other 
problem with the construction of the Delaunay triangulation. Sometimes the 
algorithm fails. This is one way that it fails.
-- 
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
 -- Umberto Eco
From: Nico S. <nic...@gm...> - 2010年02月16日 15:58:49
Well, I spend some time now setting up a framework for exporting
matplotlib generated figures to TikZ code.
You can find it on
 http://github.com/nicki/matplotlib2tikz
The workflow is essentially that you generate your plot (dont show()),
and then call matplotlib2tikz("myfile.tikz"); using a proper back-end
has been considered not useful (b/c the information that the back-ends
can access purely contain geometric information, and not semantic info
such as "this color bar belongs to plot such-and-such").
What the script can do now, essentially, is line plots, images, color
bars. Adding more functionality should not be too difficult and is
basically just a matter of actually doing it. If you're interested in
helping out then I'd think now is the time as the script is a mere 350
lines long now; just poke me on github.
Cheers,
Nico
From: Jae-Joon L. <lee...@gm...> - 2010年02月16日 15:18:50
The last line of the "on_changed" method you posted is
 mappable.set_colorbar(cb, cax)
And "set_colorbar" sets the colorbar attribute.
-JJ
On Tue, Feb 16, 2010 at 8:46 AM, Nico Schlömer <nic...@gm...> wrote:
> Works pretty well.
> I've now implemented something like
>
> ========================== *snip* ==========================
> def find_associated_colorbar( obj ):
>   for child in obj.get_children():
>       try:
>           cbar = child.colorbar
>       except AttributeError:
>           continue
>       if not cbar == None: # really necessary?
>           # if fetch was successful, cbar contains
>           # ( reference to colorbar, reference to axis
> containing colorbar )
>           return cbar[0]
>   return None
> ========================== *snip* ==========================
>
> How did you find out about the colormap attribute? Was that by taking
> a good guess in looking at the source code, or are the public
> attributes of a class documented?
>
> Cheers,
> Nico
>
>
>
> On Tue, Feb 16, 2010 at 1:18 PM, Jae-Joon Lee <lee...@gm...> wrote:
>> set_colorbar sets colorbar attribute. So I guess you can just check if
>> Mappable.colorbar is None or not.
>> Mappable.colorbar, when set, should be a tuple whose first item is an
>> image for colorbar and the second item is an colorbar axes.
>>
>> Regards,
>>
>> -JJ
>>
>> On Tue, Feb 16, 2010 at 5:26 AM, Nico Schlömer <nic...@gm...> wrote:
>>> Alright, so I dug the sources a bit and found the snippet
>>>
>>> ========================== *snip* ==========================
>>>    cb = cbar.Colorbar(cax, mappable, **kw)
>>>
>>>    def on_changed(m):
>>>      #print 'calling on changed', m.get_cmap().name
>>>      cb.set_cmap(m.get_cmap())
>>>      cb.set_clim(m.get_clim())
>>>      cb.update_bruteforce(m)
>>>
>>>    self.cbid = mappable.callbacksSM.connect('changed', on_changed)
>>>    mappable.set_colorbar(cb, cax)
>>> ========================== *snap* ==========================
>>>
>>> I guess what happens is that a Colorbar is created, and a callback
>>> function registered which adapts this very color bar whenever there is
>>> a change in color maps/limits.
>>> Well. -- I reckon that means that at the moment there's no way to tell
>>> if a ScalarMappable has a color bar associated or not. :/ -- At least
>>> I don't see how it would be possible to dig up on_changed( ) from the
>>> list of callbacks and extract cb from it.
>>>
>>> Aaand everybody: "Fea-ture request, fea-ture request!"
>>> get_colorbar() for ScalarMappables :)
>>>
>>> Cheers,
>>> Nico
>>>
>>>
>>>
>>>
>>> On Mon, Feb 15, 2010 at 7:58 PM, Nico Schlömer <nic...@gm...> wrote:
>>>>> As far as I can see, it is the other way around, i.e., mappables
>>>>> (e.g., images) know about the colorbar they are connected.
>>>>
>>>> Well yeah, that'd be even better. I'll check out the API. -- Hints
>>>> would still be appreciated of course.
>>>>
>>>> --Nico
>>>>
>>>
>>
>
1 message has been excluded from this view by a project administrator.

Showing results of 41

1 2 > >> (Page 1 of 2)
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /