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
(10) |
2
(11) |
3
(4) |
4
(2) |
5
(10) |
6
(20) |
7
(18) |
8
(32) |
9
(15) |
10
(2) |
11
(5) |
12
(7) |
13
(13) |
14
(9) |
15
(17) |
16
(10) |
17
(4) |
18
(7) |
19
(15) |
20
(16) |
21
(10) |
22
(19) |
23
(13) |
24
(4) |
25
(5) |
26
(8) |
27
(10) |
28
(17) |
29
(7) |
30
(18) |
31
(2) |
On Friday 23 May 2008 11:30:03 am Friedrich Hagedorn wrote: > On Fri, May 23, 2008 at 10:51:05AM -0400, Darren Dale wrote: > > On Friday 23 May 2008 10:35:14 am Friedrich Hagedorn wrote: > > > Hello, > > > > > > are there plan to implement a new backend for the latex proper use > > > which create the drawing comand in the pgf language? With this kind > > > of graphic creation I could overcome all the (font-) scaleing problems > > > I have when I want to include a mpl graphic in my latex document. > > > > I'm not familiar with pgf, could you provide some more information? > > pgf is a tex-based graphic language similar to ps-tricks but also > for pdftex. There are very nice graphics: > > http://www.ctan.org/get/graphics/pgf/base/doc/generic/pgf/pgfmanual.pdf > > The basic drawing is like this (a cross) > > \begin{tikzpicture} > \draw (-1.5,0) -- (1.5,0); % horizontal line > \draw (0,-1.5) -- (0,1.5); % vertical line > \draw (1,1) node{$y=x^2$}; % text label > \end{tikzpicture} > > There also exsits makro pakages for (more ore less convinent) data plots > but then you dont have the nice python interface. > > > What problems do you have with font scaling, and what additional > > capabilities do you think such an approach would offer? > > I want that fonts in the mpl graphics have the same (or otherwise related) > proerties as the main-font in my latex document. I understand this desire. John Hunter came up with the idea of the current latex support around the time that I was writing my dissertation. Like you note below, we sometimes have to iterate to get just what we want, but I think that is unavoidable. More below... > So, therefore I have to know all the font properties from my latex > document (\normalfont): type, family, size. > > The next problem is that the standard size of the mpl graphic (8, 6) inches > is too big for my latex document (0.5\linewidth). Therefore I must scale > the mpl graphic (\includegraphics[width=0.5\linewidth]{...}). But with this > scaling the font in the mpl graphic are also scaled and I have no chance > adapeting the two fonts (mpl, latex) without manual iterations. > > Ok, I could adjust the figsize but the last time I did it (long time ago) > there were other misplaced objects in the mpl graphic (I dont remember > exactly, sorry). > > But if I had the whole mpl graphic as pgf commands there would be no > problem with the font stuff, scaleing and line widths. And may be you > could extend the mpl graphic with some tricky (and eye candy) pgf > extensions (ok I am also a beginner with the pgf language but its > realy powerfull). Wouldn't this cause some problems with how the text is layed out on the canvas? The way it works now, a title can be centered over the axes because the extents of the text are known. If you allow the fonts and font sizes to be dictated by the latex document, they will end up being positioned incorrectly. P.S. please be careful that your responses go to the userlist
On Fri, May 23, 2008 at 10:51:05AM -0400, Darren Dale wrote: > On Friday 23 May 2008 10:35:14 am Friedrich Hagedorn wrote: > > Hello, > > > > are there plan to implement a new backend for the latex proper use > > which create the drawing comand in the pgf language? With this kind > > of graphic creation I could overcome all the (font-) scaleing problems > > I have when I want to include a mpl graphic in my latex document. > > I'm not familiar with pgf, could you provide some more information? pgf is a tex-based graphic language similar to ps-tricks but also for pdftex. There are very nice graphics: http://www.ctan.org/get/graphics/pgf/base/doc/generic/pgf/pgfmanual.pdf The basic drawing is like this (a cross) \begin{tikzpicture} \draw (-1.5,0) -- (1.5,0); % horizontal line \draw (0,-1.5) -- (0,1.5); % vertical line \draw (1,1) node{$y=x^2$}; % text label \end{tikzpicture} There also exsits makro pakages for (more ore less convinent) data plots but then you dont have the nice python interface. > What problems do you have with font scaling, and what additional > capabilities do you think such an approach would offer? I want that fonts in the mpl graphics have the same (or otherwise related) proerties as the main-font in my latex document. So, therefore I have to know all the font properties from my latex document (\normalfont): type, family, size. The next problem is that the standard size of the mpl graphic (8, 6) inches is too big for my latex document (0.5\linewidth). Therefore I must scale the mpl graphic (\includegraphics[width=0.5\linewidth]{...}). But with this scaling the font in the mpl graphic are also scaled and I have no chance adapeting the two fonts (mpl, latex) without manual iterations. Ok, I could adjust the figsize but the last time I did it (long time ago) there were other misplaced objects in the mpl graphic (I dont remember exactly, sorry). But if I had the whole mpl graphic as pgf commands there would be no problem with the font stuff, scaleing and line widths. And may be you could extend the mpl graphic with some tricky (and eye candy) pgf extensions (ok I am also a beginner with the pgf language but its realy powerfull). BTW. In the same way I can create very nice ciruit schematic with CircuitMacros www.ece.uwaterloo.ca/~aplevich/Circuit_macros/html/examples.pdf I hope you could understand what I mean :-) By, Friedrich
> On Friday 23 May 2008 10:35:14 am Friedrich Hagedorn wrote: >> are there plan to implement a new backend for the latex proper use >> which create the drawing comand in the pgf language? With this kind >> of graphic creation I could overcome all the (font-) scaleing problems >> I have when I want to include a mpl graphic in my latex document. On 2008年5月23日, Darren Dale wrote: > I'm not familiar with pgf, could you provide some more information? What > problems do you have with font scaling, and what additional capabilities do > you think such an approach would offer? PGF is the LaTeX portable graphics format, which can be used both with PDF production and DVI->PS production. It is a very nice innovation for LaTeX users, especially via its TikZ interface. PGF users get the full power of LaTeX for typesetting on their diagrams. This is great. For this reason, I often write PGF/TikZ code by hand when my graphs are simple. A PGF backend would be wonderful for LaTeX users who are producing documents for final distribution. All that said, I suspect the payoff to me personally would be modest, as I am almost always producting documents for later publication, at which point I generally need to provide EPS or PDF figures. If you are still interested, you may find the following to be useful: <URL:http://www.tug.org/pracjourn/2007-1/mertz/> hth, Alan Isaac
I'd like to plot values where the area of a marker is proportional to some value. How is the size value given in, say: scatter(x,y,'o',s=10) used to generate the markers? By eye it looks like the size value is proportional to the area (i.e. proportional to the radius squared for circle markers), but it would be nice to know for sure. Thanks, Neil
On Friday 23 May 2008 10:35:14 am Friedrich Hagedorn wrote: > Hello, > > are there plan to implement a new backend for the latex proper use > which create the drawing comand in the pgf language? With this kind > of graphic creation I could overcome all the (font-) scaleing problems > I have when I want to include a mpl graphic in my latex document. I'm not familiar with pgf, could you provide some more information? What problems do you have with font scaling, and what additional capabilities do you think such an approach would offer? Darren
Hello, are there plan to implement a new backend for the latex proper use which create the drawing comand in the pgf language? With this kind of graphic creation I could overcome all the (font-) scaleing problems I have when I want to include a mpl graphic in my latex document. Even gnuplot has such an backend but I dont want to use it anymore :-) By, Friedrich
Robert Garrett schrieb: > Hi, > I'd like to use Python to plot data in real-time. I've created a GUI > using wxPython and have embedded a Matplotlib graph into a pane. My > problem is that I don't know the best way to update the graph. What's > the recommended method for this? First use the set_data (or set_xdata, set_ydata) methods of the artists which you might have created with the plot command. Then redraw the figure on screen using a .canvas.draw() call of your figure object. > The data comes from a peripheral device connected to the PC, so I also > need a way of regularly polling the hardware. I've managed this using > a separate thread, but this doesn't work for updating the graph (Xlib > complained). In wxPython changing the GUI should only happen from the main thread. Use wx.PostEvent with some user defined event object to send the newly aquired data from the acquisition thread to the main thread. In the event handling routine update the graph as described above. See the threading demo of the wxPython demo how to implement this. Gregor
Hi, I'd like to use Python to plot data in real-time. I've created a GUI using wxPython and have embedded a Matplotlib graph into a pane. My problem is that I don't know the best way to update the graph. What's the recommended method for this? The data comes from a peripheral device connected to the PC, so I also need a way of regularly polling the hardware. I've managed this using a separate thread, but this doesn't work for updating the graph (Xlib complained). I'm sure this must be something that people have done many times before, but I've been unable to find a simple explanation on how to achieve it! Any help or suggestions would be much appreciated. Thanks, Rob
On Thu, May 22, 2008 at 03:25:41PM -0700, Christopher Brown wrote: > Hi Users, > > What is the best way to add a subscript to a tick label using the > default font? Hm, could you give a short example of what you want? I do subscripts with this code: In [1]: subplot(111) Out[1]: <matplotlib.axes.AxesSubplot object at 0x8cbbf2c> In [2]: xticks((0, 0.5, 1), (r'$t_0$', r'$t_1$', r'$t_2$'), fontsize=18) Out[2]: ([<matplotlib.axis.XTick object at 0x8cd028c>, <matplotlib.axis.XTick object at 0x8ffb0ac>, <matplotlib.axis.XTick object at 0x8ffb0cc>], <a list of 3 Text xticklabel objects>) But sure this is not the best way to do it :-) By, Friedrich
Hi Users, What is the best way to add a subscript to a tick label using the default font? -- Chris
You didn't mention the version of matplotlib you are using. There are some known bugs using NaNs on 0.90.x and 0.91.x that have been fixed on the trunk. Unfortunately, it will be difficult to backport these fixes. Have you tried using masked arrays instead of arrays with NaNs? Also, can you provide a standalone example that reproduces this error (including specific data?) so that we can further investigate? Cheers, Mike Fabrice Silva wrote: > Hello, > > I want to plot data containing nan values, but it seems that matplotlib > forget some non-nan values near nan values. > In the attached image, I plotted in blue the array for increasing of > x-data, and in red for decreasing x-data : > > import numpy as NX > > In [1]: from pylab import figure, plot, show > In [2]: figure(2) > Out[2]: <matplotlib.figure.Figure instance at 0x8445c8c> > > In [3]: type(Freq) > Out[3]: <type 'numpy.ndarray'> > > In [4]: NX.any(NX.isnan(Freq)) > Out[4]: True > > In [5]: type(Grillefr) > Out[5]: <type 'numpy.ndarray'> > > In [6]: NX.any(NX.isnan(Grillefr)) > Out[6]: False > > In [7]: plot(Grillefr, Freq, 'b', lw=2.) > Out[7]: [<matplotlib.lines.Line2D instance at 0x9245e8c>] > > In [8]: plot(Grillefr[::-1], Freq[::-1], 'r', lw=0.5) > Out[8]: [<matplotlib.lines.Line2D instance at 0x9245fec>] > > In [9]: show() > > with Grillefr containing values from 100 to 2000. > In the matplotlibrc, I have : > maskedarray : True > > Can anybody explain me why some points are not drawn by matplotlib ? > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > ------------------------------------------------------------------------ > > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users >
On Wed, May 21, 2008 at 10:57 AM, PaterMaximus <Pat...@go...> wrote: > I want to make one scatter plot and use the same scales on another. I think > I seen getting the Axes from the first scatter plot using v=axis() and then > setting them on second with axis(v) but I can not get to work. Any help > appreciated Try using shared scales: ax1 = subplot(211) ax2 = subplot(212, sharex=ax1, sharey=ax1) JDH
On Thu, May 22, 2008 at 9:45 AM, Jouni K. Seppänen <jk...@ik...> wrote: > I think this behavior of legend is suboptimal, but there is a logic to > it: by default you label objects in the order you draw them, and the > histogram plot happens to consist of several similarly-colored objects. The best solution would be to rewrite the hist to use a collection. This would make legend behave properly, would be a lot faster, but would break a fair amount of legend code. Probably a good thing to do for 0.98 JDH
Correction : > In the matplotlibrc, I have : > maskedarray : False -- Fabrice Silva <si...@lm...> LMA UPR CNRS 7051 - équipe S2M
On 2008年5月22日, Friedrich Hagedorn apparently wrote: > I hope I can change my habit to type 'g' instead of 'r'. Or use an email client that allows you to register your email lists to address this problem. (Such as Mahogany mail.) Cheers, Alan Isaac
Hello, I want to plot data containing nan values, but it seems that matplotlib forget some non-nan values near nan values. In the attached image, I plotted in blue the array for increasing of x-data, and in red for decreasing x-data : import numpy as NX In [1]: from pylab import figure, plot, show In [2]: figure(2) Out[2]: <matplotlib.figure.Figure instance at 0x8445c8c> In [3]: type(Freq) Out[3]: <type 'numpy.ndarray'> In [4]: NX.any(NX.isnan(Freq)) Out[4]: True In [5]: type(Grillefr) Out[5]: <type 'numpy.ndarray'> In [6]: NX.any(NX.isnan(Grillefr)) Out[6]: False In [7]: plot(Grillefr, Freq, 'b', lw=2.) Out[7]: [<matplotlib.lines.Line2D instance at 0x9245e8c>] In [8]: plot(Grillefr[::-1], Freq[::-1], 'r', lw=0.5) Out[8]: [<matplotlib.lines.Line2D instance at 0x9245fec>] In [9]: show() with Grillefr containing values from 100 to 2000. In the matplotlibrc, I have : maskedarray : True Can anybody explain me why some points are not drawn by matplotlib ? -- Fabrice Silva <si...@lm...> LMA UPR CNRS 7051 - équipe S2M
> p.setp(ax1.get_yticklabels(), color='r') This worked! Thanks a lot! Chiara > To: mat...@li... > From: jk...@ik... > Date: 2008年5月22日 17:52:09 +0300 > Subject: Re: [Matplotlib-users] changing ticklabels color > > Chiara Caronna <chi...@ho...> writes: > > > ax1=p.subplot(212) > > ax1.set_xlabel('t [sec]') > > ax1.set_ylabel('g^2(q,t)') > > ax1.set_yticklabels(color='r') > > You could do > > for label in ax1.get_yticklabels(): label.set_color('r') > > or use the setp shortcut: > > p.setp(ax1.get_yticklabels(), color='r') > > -- > Jouni K. Seppänen > http://www.iki.fi/jks > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users _________________________________________________________________ Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us
On Thu, May 22, 2008 at 05:59:23PM +0300, Jouni K. Seppänen wrote: > Friedrich Hagedorn <fri...@gm...> writes: > > > could you set the right reply-adress in the mails from the > > matplotlib mailinglist? > > This is something of a controversial issue. One side is presented at > > http://www.unicom.com/pw/reply-to-harmful.html > > and I'm sure the other one has a web page somewhere, too. On lists that > do not munge the reply-to address, such as the matplotlib lists, you > have two options: you can reply to the sender only ('r' in mutt) or > reply to everyone ('g'). On lists that do munge the address, both > commands reply to the complete list. Ok, I test it with 'g' by this reply, and it works. I hope I can change my habit to type 'g' instead of 'r'. On Thu, May 22, 2008 at 04:59:39PM +0200, Johann Rohwer wrote: > This has been discussed before. See: > > http://sourceforge.net/mailarchive/message.php?msg_id=4756A726.1080104%40gmx.net Ah, I see the discussion. I am for 'r' :-) By, Friedrich
Chiara Caronna <chi...@ho...> writes: > ax1=p.subplot(212) > ax1.set_xlabel('t [sec]') > ax1.set_ylabel('g^2(q,t)') > ax1.set_yticklabels(color='r') You could do for label in ax1.get_yticklabels(): label.set_color('r') or use the setp shortcut: p.setp(ax1.get_yticklabels(), color='r') -- Jouni K. Seppänen http://www.iki.fi/jks
This has been discussed before. See: http://sourceforge.net/mailarchive/message.php?msg_id=4756A726.1080104%40gmx.net Johann Friedrich Hagedorn wrote: > Hello List-Admin, > > could you set the right reply-adress in the mails from the > matplotlib mailinglist? > > Everytime when I what to reply to a message I have to set the right > email-adress to > > mat...@li... > > otherwise the email would sent only as a privat mail. > > I use mutt and on all other mailinglist I have no problem. So I think > this is a matplotlib-ml problem.
On Thu, May 22, 2008 at 02:30:24PM +0000, Chiara Caronna wrote: > Hello, > I would like to change the color of the yticklabels. I tried to use this > command: > > ax1=p.subplot(212) [...] > ax1.set_yticklabels(color='r') * Solution 1: In [1]: ax1=subplot(111) In [2]: setp(ax1.get_yaxis().get_major_ticklabels(), color='r') * Solution 2: In [1]: ax1=subplot(111) In [2]: for label in ax1.get_yaxis().get_majorticklabels(): ...: label.set_color('r') ...: ...: In [3]: draw() May be there is a shorter solution but I dont know of it :-) By, Friedrich
Friedrich Hagedorn <fri...@gm...> writes: > could you set the right reply-adress in the mails from the > matplotlib mailinglist? This is something of a controversial issue. One side is presented at http://www.unicom.com/pw/reply-to-harmful.html and I'm sure the other one has a web page somewhere, too. On lists that do not munge the reply-to address, such as the matplotlib lists, you have two options: you can reply to the sender only ('r' in mutt) or reply to everyone ('g'). On lists that do munge the address, both commands reply to the complete list. -- Jouni K. Seppänen http://www.iki.fi/jks
David Simpson <dav...@ch...> writes: > This is probably my lack of knowledge of python, but how do I set up > legend labels for some bar-plots that have been produced inside a > function. For example, the following will nicely plot my bar-plots, but > then legend doesn't know about the colours used, so here just uses black > for both labels. Legends for multiple histograms don't behave the way people expect, because the colors are taken bar by bar, first from one histogram, then from the second histogram, etc. You need to take just one bar from each histogram and pass them as the first argument to legend: ------------------------------------------------------------------------ from pylab import * x=arange(0,5) y=array([ 1.2, 3.4, 5.4, 2.3, 1.0]) z=array([ 2.2, 0.7, 0.4, 1.3, 1.2]) def plotb(x,y,col): p=bar(x,y,color=col) return p[0] p1 = plotb(x,y,'k') p2 = plotb(x+0.4,z,'y') legend((p1, p2), ('YYY','ZZZ')) show() ------------------------------------------------------------------------ I think this behavior of legend is suboptimal, but there is a logic to it: by default you label objects in the order you draw them, and the histogram plot happens to consist of several similarly-colored objects. -- Jouni K. Seppänen http://www.iki.fi/jks
Hello List-Admin, could you set the right reply-adress in the mails from the matplotlib mailinglist? Everytime when I what to reply to a message I have to set the right email-adress to mat...@li... otherwise the email would sent only as a privat mail. I use mutt and on all other mailinglist I have no problem. So I think this is a matplotlib-ml problem. Thanks, Friedrich
On Thu, May 22, 2008 at 02:52:13PM +0200, David Simpson wrote: > This is probably my lack of knowledge of python, but how do I set up > legend labels for some bar-plots that have been produced inside a > function. For example, the following will nicely plot my bar-plots, but > then legend doesn't know about the colours used, so here just uses black > for both labels. I'd like the labels to have the same colour as the bars > generated inside plotb. (I am using a function here as my real code has > extra stuff to calculate error-bars and suchlike for each data set.) > > x=arange(0,5) > y=array([ 1.2, 3.4, 5.4, 2.3, 1.0]) > z=array([ 2.2, 0.7, 0.4, 1.3, 1.2]) > > def plotb(x,y,col): > p=bar(x,y,color=col) > > plotb(x,y,'k') > plotb(x+0.4,z,'y') > > legend(('YYY,'ZZZ')) > > I tried passing the object "p" through the plotb argument list, but > python didn't like that. (I am just learning python, and so far haven't > seen how to pass such objects around. You could return the plotted lines from the function plotb. Here is my attempt: In [1]: x=arange(0,5) In [2]: y=array([ 1.2, 3.4, 5.4, 2.3, 1.0]) In [3]: z=array([ 2.2, 0.7, 0.4, 1.3, 1.2]) In [4]: def plotb(x,y,col): ...: lines = bar(x,y,color=col) ...: return lines ...: In [5]: l1 = plotb(x,y,'k') In [6]: l2 = plotb(x+0.4,z,'y') In [7]: legend((l1[0], l2[0]), ('YYY','ZZZ')) Out[7]: <matplotlib.legend.Legend object at 0x908dc6c> The legend() function could label any line object. So every single bar-line could be listed in the legend. But I think you would only have one from each color, so I have choosen the first: l1[0] and l2[0]. Is this what you what? By, Friedrich