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
(2) |
2
(4) |
3
(16) |
4
(4) |
5
(15) |
6
(16) |
7
(6) |
8
(4) |
9
(9) |
10
(5) |
11
(8) |
12
(14) |
13
(19) |
14
(21) |
15
(8) |
16
(6) |
17
(10) |
18
(22) |
19
(15) |
20
(7) |
21
(21) |
22
(1) |
23
(6) |
24
(16) |
25
(12) |
26
(11) |
27
(27) |
28
(7) |
29
|
30
(4) |
31
(5) |
|
|
|
|
|
On Thu, Jan 6, 2011 at 11:47 AM, Benjamin Root <ben...@ou...> wrote: > On Thu, Jan 6, 2011 at 12:57 AM, Sebastian Voigt <sv...@gm...> wrote: > >> Am 06.01.2011 02:14, schrieb Benjamin Root: >> >> On Wed, Jan 5, 2011 at 6:15 PM, Sebastian Voigt <sv...@gm...> wrote: >> >>> I've been running into the well known rendering problems with mplot3d's >>> bar3d function. After two days of trying to get acceptable results >>> without success: Is it possible to simply disable z-sorting (whoops)? >>> >>> I want to generate static plots from experimental data, all using the >>> same perspective, so I know the order of the bars to be plotted. It's a >>> no-brainer to provide the data vectors in this appropriate order, which >>> I tried too - didn't work. Even if I provide explicit zorders for all >>> Poly3dCollections in axes.collections (single-plotting each bar), >>> everything gets messed up after showing the plot window. >>> >>> So is there any way to create the bars just in the order of the data >>> vectors passed to bar3d (or keep the order/zorder in axes.collections)? >>> >>> >>> - Sebastian Voigt - >>> >>> >> There are well-known rendering issues with mplot3d in general, but I am >> not aware of one with respect to bar3d. Can you please include a image of >> the rendering defect that you are seeing? >> >> And no, there is no way to disable z-sorting that I am aware of because it >> is inherent in matplotlib's system. mplot3d merely utilizes the drawing >> facilities that matplotlib provides. >> >> Ben Root >> >> >> It's exactly the same problem as described in >> >> >> http://www.mail-archive.com/mat...@li.../msg15243.html >> >> see the second sample pic in this post. If I cannot disable z-sorting, how >> can I control it? Artist have a set_zorder() method, but providing correct >> z-levels for all my artists seems to be ignored. >> >> Sebastian >> > > Sebastian, looking at those images, I have to wonder if there is a bug in > how bar3d is reporting the z-order. These rendering mistakes do not seem to > follow the same patterns that I have seen with manually setting polygon > objects. I will take a deeper look into it. > > Ben Root > > Ok, I have figure out what is wrong here. First of all, thank you for pointing out this whole issue, because my investigations lead me to realize some other bugs that are currently in the development trunk (I have to see if they are in the 1.0.1 branch as well). As for the issue with bar3d. The graphs look much better when you plot each row of bars (or even better if you plot each bar separately). This is because bar3d creates a Poly3DCollection and will do its best to sort the collection elements internally with respect to each other. However, when you have two objects from two separate Poly3DCollections (or any two 3D collection objects, for that matter) that occupy the same region in space, then you will have problems. Each Poly3DCollection object reports a scalar zsort value that is supposed to represent the zsort value of all its elements. This is fine if the collections are spatially distinct, or if the scalar zsort value is equal to the zsort value of all the elements. Try out the attached modified script. You can see that by looping through the bars, you get a much better result (although it is still not perfect due to the already established issues). I am not exactly sure how to resolve this, but at least it is documented here for posterity. Ben Root
On Thu, Jan 6, 2011 at 3:06 PM, aradea hakim <ara...@gm...> wrote: > Hi all, > I am trying to install matplotlib1.0.1 on my machine but somehow I keep on > getting a corrupt .tar.gz file. > This is the error message: > tar: Skipping to next header > gzip: stdin: invalid compressed data--crc error > gzip: stdin: invalid compressed data--length error > tar: Child returned status 1 > tar: Exiting with failure status due to previous errors > Any help would be appreciated. Thank you. Seems to work for me. What platform are you on -- can you verify the md5 sum of your download? Here is what I get (my md5 and sha sums match those reported on the sf download site) jdhunter@uqbar:tmp> wget http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.0.1/matplotlib-1.0.1.tar.gz ...snip 2011年01月06日 13:18:25 (159 KB/s) - `matplotlib-1.0.1.tar.gz' saved [13285166/13285166] jdhunter@uqbar:tmp> md5sum matplotlib-1.0.1.tar.gz 2196c0482d5b33dc8d33f67bbafc1323 matplotlib-1.0.1.tar.gz jdhunter@uqbar:tmp> sha1sum matplotlib-1.0.1.tar.gz c7a832f28a66817626e7a8af21e14ea0e15f4008 matplotlib-1.0.1.tar.gz jdhunter@uqbar:tmp> tar tvf matplotlib-1.0.1.tar.gz |tail -5 -rw-r--r-- jdhunter/jdhunter 9582 2010年07月06日 18:41 matplotlib-1.0.1/lib/mpl_toolkits/axes_grid1/inset_locator.py -rw-r--r-- jdhunter/jdhunter 16648 2010年07月06日 18:41 matplotlib-1.0.1/lib/mpl_toolkits/axes_grid1/parasite_axes.py -rw-r--r-- jdhunter/jdhunter 25637 2010年07月06日 18:41 matplotlib-1.0.1/lib/mpl_toolkits/axes_grid1/axes_grid.py -rw-r--r-- jdhunter/jdhunter 4658 2010年07月06日 18:41 matplotlib-1.0.1/lib/mpl_toolkits/axes_grid1/axes_rgb.py -rw-r--r-- jdhunter/jdhunter 27358 2010年08月03日 07:22 matplotlib-1.0.1/lib/mpl_toolkits/axes_grid1/colorbar.py
Hi all, I am trying to install matplotlib1.0.1 on my machine but somehow I keep on getting a corrupt .tar.gz file. This is the error message: * * *tar: Skipping to next header* * * *gzip: stdin: invalid compressed data--crc error* * * *gzip: stdin: invalid compressed data--length error* *tar: Child returned status 1* *tar: Exiting with failure status due to previous errors* Any help would be appreciated. Thank you. -- Aradea R. Hakim
On Thu, Jan 6, 2011 at 12:57 AM, Sebastian Voigt <sv...@gm...> wrote: > Am 06.01.2011 02:14, schrieb Benjamin Root: > > On Wed, Jan 5, 2011 at 6:15 PM, Sebastian Voigt <sv...@gm...> wrote: > >> I've been running into the well known rendering problems with mplot3d's >> bar3d function. After two days of trying to get acceptable results >> without success: Is it possible to simply disable z-sorting (whoops)? >> >> I want to generate static plots from experimental data, all using the >> same perspective, so I know the order of the bars to be plotted. It's a >> no-brainer to provide the data vectors in this appropriate order, which >> I tried too - didn't work. Even if I provide explicit zorders for all >> Poly3dCollections in axes.collections (single-plotting each bar), >> everything gets messed up after showing the plot window. >> >> So is there any way to create the bars just in the order of the data >> vectors passed to bar3d (or keep the order/zorder in axes.collections)? >> >> >> - Sebastian Voigt - >> >> > There are well-known rendering issues with mplot3d in general, but I am not > aware of one with respect to bar3d. Can you please include a image of the > rendering defect that you are seeing? > > And no, there is no way to disable z-sorting that I am aware of because it > is inherent in matplotlib's system. mplot3d merely utilizes the drawing > facilities that matplotlib provides. > > Ben Root > > > It's exactly the same problem as described in > > > http://www.mail-archive.com/mat...@li.../msg15243.html > > see the second sample pic in this post. If I cannot disable z-sorting, how > can I control it? Artist have a set_zorder() method, but providing correct > z-levels for all my artists seems to be ignored. > > Sebastian > Sebastian, looking at those images, I have to wonder if there is a bug in how bar3d is reporting the z-order. These rendering mistakes do not seem to follow the same patterns that I have seen with manually setting polygon objects. I will take a deeper look into it. Ben Root
On Thu, Jan 6, 2011 at 7:20 AM, Jae-Joon Lee <lee...@gm...> wrote: > I think this should be more like a feature request (rather than a > bug). Legend only support simple artists such as > lines/patches/collections. I disagree about this not being a bug. I understand that it can be difficult to implement, however legend produce the wrong result. >This is mentioned in the documentation > (http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.legend) > but may be not explicit enough. I couldn't find any reference about this in the documentation. Alejandro.
On Wed, Jan 5, 2011 at 9:24 PM, Benjamin Root <ben...@ou...> wrote: > To prevent it from getting lost, could you please > file a report on our bug tracker? Done: https://sourceforge.net/tracker/?func=detail&aid=3152447&group_id=80706&atid=560720 I think the right behavior should mimic what Matlab does. I added the plot generated by Matlab in the bug report. Alejandro.
On Thu, Jan 6, 2011 at 1:24 PM, Benjamin Root <ben...@ou...> wrote: > I apologize for how long it has taken to get back to you. I can confirm > your bug, and it is indeed a bug. However, I am not sure how exactly it > should be dealt with. To prevent it from getting lost, could you please > file a report on our bug tracker? I think this should be more like a feature request (rather than a bug). Legend only support simple artists such as lines/patches/collections. This is mentioned in the documentation (http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.legend) but may be not explicit enough. Implementing legend for stem command is not very straight forward as command like stem create multiple artists. I prefer commands like stem to return a single container artist, but this has potential to break the old code. For the original question, you may use proxy artist (http://matplotlib.sourceforge.net/users/legend_guide.html#using-proxy-artist). However, I'm afraid none of the currently supported artists is close to what you want. And it is not easy (for a normal user) to create a customized legend unfortunately. Regards, -JJ
On Thu, Jan 6, 2011 at 12:43 PM, Benjamin Root <ben...@ou...> wrote: > I can confirm the problem, and I have a few suspects as to the cause. Most > notably that the legend code probably assumes that it is looking for line > objects, not patch objects and starts using its own color cycler when it > can't get a list of colors to correspond with its list of labels. The main issue here is that a single "bar" command creates multiple patch artists. There is not much thing legend code can do. I guess this is where documentation needs to be improved though. Regards, -JJ
Paul Ivanov wrote: > Neal Becker, on 2011年01月05日 08:19, wrote: >> I want to plot semilogy with major and minor grid. I tried: >> >> plt.grid(which='both') >> >> But 2 problems: >> >> 1) For semilogy, most of my viewers will expect to see 10 minor >> ticks/major tick. I got 5. How do I change it? > > Hi Neal, > > odd, it works here. (See attached image) > > In [1]: plt.semilogy(((np.random.rand(50)*9+1))) > > If your problem persists, can you provide a small example where > this does not work? You might check the minor locator - make > sure that it is base 10 Perhaps because my data covered a large range 10**-7 ... 10**0? I'll try some experiments. I had to force it with: fig.get_axes()[0].set_yticks ([a*(10**b) for b in xrange (-7,0) for a in xrange (1,10) ], minor=True) > In [2]: plt.gca().yaxis.minor.locator._base > Out[2]: 10.0 > >> 2) I'd like the major ticks to be solid lines, and minor ticks >> to be dashed. I got all dashed. > > In [3]: plt.grid(which='major', linestyle='solid') > In [4]: plt.grid(which='minor', linestyle='dashed') >
Got it now. Sorry about the confusion...by working for me I meant that set of commands ran and made the standard colorbar. I just installed ipython (Ubuntu OS). Will try the interactive way as well. All very new. I've used PGPLOT for ~15 years. Thanks again. Mike --- On Wed, 1/5/11, Paul Ivanov <piv...@gm...> wrote: > From: Paul Ivanov <piv...@gm...> > Subject: Re: [Matplotlib-users] defining a custom RGB colormap > To: mat...@li... > Date: Wednesday, January 5, 2011, 7:15 PM > Michael Rawlins, on 2011年01月05日 > 14:42, wrote: > > Thanks for the detailed tutorial. I'm getting errors > when I > > attempt to use plt.subplots(1,1) and the newcm > assignment. > > > > Traceback (most recent call last): > > File "colorbar_Mytest2.py", line 17, > in <module> > > f, ax = plt.subplots(1,1) > > AttributeError: 'module' object has no attribute > 'subplots' > > Ah, you must be using an older version of matplotlib - > subplots > is a (recently added) convenience shortcut for: > > f = plt.figure() > ax = plt.subplot(1,1,1) > > It comes in handy when you're making lots of subplots by > letting > you do it with one call, instead of doing that one by one > (as I > have rewritten below, so you could run without having to > upgrade > your matplotlib. > > > Also, what does In and Out do, as in Out[68]: > 0.34999? > > That's just the prompts from IPython - I *highly* recommend > using > IPython in place of the default python shell for > interactive usage. > In[10] is what I typed, Out[10] is the result of my > command at > In[10]. > > > Here are just a few of the errors I'm getting when > executing > > colorbar command with newcm. > > > Here's a simplified version that works for me: > > ouch! this code doesn't do quite what you want > > > from pylab import * > > Try to avoid doing this - because you will get unintended > consequences such as the one on the following line. > > > vals = norm(np.linspace(14,40,1000)) > > This was meant to go *after* you initialize the 'norm' > variable > with norm = mpl.colors.Normalize(...). That's the norm I > meant to be using. But because of the "from pylab import *" > line, > the norm function from numpy was imported - which is what > was being > used on that line as written in your code. > > so the vals= line is equivalent to > > vals = numpy.norm(np.linspace(14,40,1000)) > > which meant vals got assigned the value 886.25397758173483, > and > not at all what we wanted. We wanted it to get an array of > 1000 > numbers: > > vals = mpl.colors.Normalize(vmin=0, > vmax=40)(np.linspace(14,40,1000)) > > That's where your trouble with newcm were coming from. > Here's the > complete example again, I've renamed the 'norm' variable > to > 'rawlins_norm' for clarity. > > import matplotlib as mpl > import matplotlib.pyplot as plt > from matplotlib import cm > import numpy as np > > # Make a figure and axes with dimensions as desired. > fig = plt.figure(figsize=(8,3)) > ax1 = plt.subplot(2,1,1) > ax2 = plt.subplot(2,1,2) > > # Set the colormap and norm to correspond to the data for > which > # the colorbar will be used. > rawlins_norm = mpl.colors.Normalize(vmin=0, > vmax=40) # here set colorbar min/max > # the right place for vals > vals = rawlins_norm(np.linspace(14,40,1000)) > newcm = cm.colors.ListedColormap(cm.hot_r(vals)) > > cb1 = mpl.colorbar.ColorbarBase(ax1, cmap=cm.hot_r, > > > norm=rawlins_norm, > > > orientation='horizontal') > > cb1.set_label('"percent"') > cb2 = mpl.colorbar.ColorbarBase(ax2, cmap=newcm, > > > orientation='horizontal') > > cb2.set_label("colormap interval 0.0-1.0") > plt.subplots_adjust(hspace=.7, bottom=.2) > > #comment out the next line to see the original (0-40 > colormap) > ax1.set_xlim(rawlins_norm((14,40))) > plt.show() > > > best, > -- > Paul Ivanov > 314 address only used for lists, off-list direct > email at: > http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 > > -----Inline Attachment Follows----- > > ------------------------------------------------------------------------------ > Learn how Oracle Real Application Clusters (RAC) One Node > allows customers > to consolidate database storage, standardize their database > environment, and, > should the need arise, upgrade to a full multi-node Oracle > RAC database > without downtime or disruption > http://p.sf.net/sfu/oracle-sfdevnl > -----Inline Attachment Follows----- > > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users >
Hi Ben, Thanks for your nicer and working code! It works perfectly and is indeed clean. Up to now I didn't noticed any problem with the positioning of the legend. Best regards, Alain From: ben...@gm... [mailto:ben...@gm...] On Behalf Of Benjamin Root Sent: Thursday, 06 January, 2011 04:43 To: Alain Pascal Frances Cc: mat...@li... Subject: Re: [Matplotlib-users] Legend in a multibars chart On Wed, Jan 5, 2011 at 7:19 AM, Alain Pascal Frances <fra...@it...<mailto:fra...@it...>> wrote: Hi, I'm plotting two subplots using bar charts, the first one contains one dataset (one bar for each abscissa value), the second 3 dataset (3 bars for each abscissa value, each one with its own color). The legend of the multibars chart is not correct, it shows the color of the first dataset for all the bars legend. Note that it works correctly with matplotlib.pyplot.plot instead of matplotlib.pyplot.bar. Any idea to fix it? Thanks, A.Frances I can confirm the problem, and I have a few suspects as to the cause. Most notably that the legend code probably assumes that it is looking for line objects, not patch objects and starts using its own color cycler when it can't get a list of colors to correspond with its list of labels. As a work-around, you can add a label keyword to the call to bar() and not bother giving legend() a list of labels. Here is a cleaned-up version of your first code. Note I also took a moment to take advantage of python syntax and better numpy/matplotlib coding styles. The only issue seems to be that there might be a bug with respect to positioning the legend: import matplotlib.pyplot as plt import numpy as np strTitle = 'Bars plot - multi data and legend' x = np.arange(10) y1 = 1.0 + np.random.random(x.shape) y2 = 0.5 + np.random.random((3, len(x))) lbl_y1 = 'bar 1' lbl_type = ['red', 'green', 'blue'] colors_y2 = ([1,0,0],[0,1,0],[0,0,1]) lbls_y2 = ["bar 2 " + lbl for lbl in lbl_type] fig = plt.figure() ax1 = fig.add_subplot(2,1,1) ax1.set_title("Single data") ax1.bar(x, y1, color='purple', linewidth=0, align='edge', width=0.8, label=lbl_y1) ax1.legend(loc=0) ax1.set_xticks(x) ax2 = fig.add_subplot(2,1,2, sharex=ax1) ax2.set_title("Multi data") for i, (y, color, lbl) in enumerate(zip(y2, colors_y2, lbls_y2)) : ax2.bar(x+(0.8*float(i)/len(y2)), y, color=color, label=lbl, linewidth=0, align='edge', width=(0.8/len(y2))) ax2.legend(loc=0) fig.subplots_adjust(left=0.05, bottom=0.1, right=0.95, top=0.95, wspace=0.1, hspace=0.15) plt.show() I hope this helps! Ben Root
On Fri, Dec 17, 2010 at 4:03 PM, Alejandro Weinstein < ale...@gm...> wrote: > Hi: > > I want to add a legend to a stem plot with two plots. The basic code is: > > ########################### > from pylab import * > > x = [1,2,3,4,5] > y1 = [1, 2, 3, 4, 5] > y2 = [5, 4, 3, 2, 1] > > subplot(211) > plot(x, y1, 'rx-') > plot(x, y2, 'bx-') > legend(('a', 'b')) > > subplot(212) > stem(x, y1, 'r') > stem(x,y2, 'b') > legend(('a', 'b')) > > show() > ########################### > > The left subplot is the same plot using plot instead of stem. You can > see the result here: http://imagebin.org/128376 . > > I expect the legend for the stem case to look similar to the plot > case, however, for the stem, I get the two labels of the legend > associated with the first stem command: 'a' linked to the marker and > 'b' linked to the stem line. > > Is there any way to fix this? Is this a bug? > > Alejandro. > > Alejandro, I apologize for how long it has taken to get back to you. I can confirm your bug, and it is indeed a bug. However, I am not sure how exactly it should be dealt with. To prevent it from getting lost, could you please file a report on our bug tracker? http://sourceforge.net/tracker/?group_id=80706 That would be greatly appreciated. Ben Root P.S. - On a unrelated note, it is not good coding style to do a "from pylab import *" as pylab brings in *many* functions and variables into the main namespace and will likely collide with one of your own variables and/or functions.
On Wed, Jan 5, 2011 at 7:19 AM, Alain Pascal Frances <fra...@it...>wrote: > Hi, > > I'm plotting two subplots using bar charts, the first one contains one > dataset (one bar for each abscissa value), the second 3 dataset (3 bars for > each abscissa value, each one with its own color). The legend of the > multibars chart is not correct, it shows the color of the first dataset for > all the bars legend. > Note that it works correctly with matplotlib.pyplot.plot instead of > matplotlib.pyplot.bar. > Any idea to fix it? > Thanks, > > A.Frances > > I can confirm the problem, and I have a few suspects as to the cause. Most notably that the legend code probably assumes that it is looking for line objects, not patch objects and starts using its own color cycler when it can't get a list of colors to correspond with its list of labels. As a work-around, you can add a label keyword to the call to bar() and not bother giving legend() a list of labels. Here is a cleaned-up version of your first code. Note I also took a moment to take advantage of python syntax and better numpy/matplotlib coding styles. The only issue seems to be that there might be a bug with respect to positioning the legend: import matplotlib.pyplot as plt import numpy as np strTitle = 'Bars plot - multi data and legend' x = np.arange(10) y1 = 1.0 + np.random.random(x.shape) y2 = 0.5 + np.random.random((3, len(x))) lbl_y1 = 'bar 1' lbl_type = ['red', 'green', 'blue'] colors_y2 = ([1,0,0],[0,1,0],[0,0,1]) lbls_y2 = ["bar 2 " + lbl for lbl in lbl_type] fig = plt.figure() ax1 = fig.add_subplot(2,1,1) ax1.set_title("Single data") ax1.bar(x, y1, color='purple', linewidth=0, align='edge', width=0.8, label=lbl_y1) ax1.legend(loc=0) ax1.set_xticks(x) ax2 = fig.add_subplot(2,1,2, sharex=ax1) ax2.set_title("Multi data") for i, (y, color, lbl) in enumerate(zip(y2, colors_y2, lbls_y2)) : ax2.bar(x+(0.8*float(i)/len(y2)), y, color=color, label=lbl, linewidth=0, align='edge', width=(0.8/len(y2))) ax2.legend(loc=0) fig.subplots_adjust(left=0.05, bottom=0.1, right=0.95, top=0.95, wspace=0.1, hspace=0.15) plt.show() I hope this helps! Ben Root
On Wed, Jan 5, 2011 at 6:15 PM, Sebastian Voigt <sv...@gm...> wrote: > I've been running into the well known rendering problems with mplot3d's > bar3d function. After two days of trying to get acceptable results > without success: Is it possible to simply disable z-sorting (whoops)? > > I want to generate static plots from experimental data, all using the > same perspective, so I know the order of the bars to be plotted. It's a > no-brainer to provide the data vectors in this appropriate order, which > I tried too - didn't work. Even if I provide explicit zorders for all > Poly3dCollections in axes.collections (single-plotting each bar), > everything gets messed up after showing the plot window. > > So is there any way to create the bars just in the order of the data > vectors passed to bar3d (or keep the order/zorder in axes.collections)? > > > - Sebastian Voigt - > > There are well-known rendering issues with mplot3d in general, but I am not aware of one with respect to bar3d. Can you please include a image of the rendering defect that you are seeing? And no, there is no way to disable z-sorting that I am aware of because it is inherent in matplotlib's system. mplot3d merely utilizes the drawing facilities that matplotlib provides. Ben Root
I've been running into the well known rendering problems with mplot3d's bar3d function. After two days of trying to get acceptable results without success: Is it possible to simply disable z-sorting (whoops)? I want to generate static plots from experimental data, all using the same perspective, so I know the order of the bars to be plotted. It's a no-brainer to provide the data vectors in this appropriate order, which I tried too - didn't work. Even if I provide explicit zorders for all Poly3dCollections in axes.collections (single-plotting each bar), everything gets messed up after showing the plot window. So is there any way to create the bars just in the order of the data vectors passed to bar3d (or keep the order/zorder in axes.collections)? - Sebastian Voigt -
Michael Rawlins, on 2011年01月05日 14:42, wrote: > Thanks for the detailed tutorial. I'm getting errors when I > attempt to use plt.subplots(1,1) and the newcm assignment. > > Traceback (most recent call last): > File "colorbar_Mytest2.py", line 17, in <module> > f, ax = plt.subplots(1,1) > AttributeError: 'module' object has no attribute 'subplots' Ah, you must be using an older version of matplotlib - subplots is a (recently added) convenience shortcut for: f = plt.figure() ax = plt.subplot(1,1,1) It comes in handy when you're making lots of subplots by letting you do it with one call, instead of doing that one by one (as I have rewritten below, so you could run without having to upgrade your matplotlib. > Also, what does In and Out do, as in Out[68]: 0.34999? That's just the prompts from IPython - I *highly* recommend using IPython in place of the default python shell for interactive usage. In[10] is what I typed, Out[10] is the result of my command at In[10]. > Here are just a few of the errors I'm getting when executing > colorbar command with newcm. > Here's a simplified version that works for me: ouch! this code doesn't do quite what you want > from pylab import * Try to avoid doing this - because you will get unintended consequences such as the one on the following line. > vals = norm(np.linspace(14,40,1000)) This was meant to go *after* you initialize the 'norm' variable with norm = mpl.colors.Normalize(...). That's the norm I meant to be using. But because of the "from pylab import *" line, the norm function from numpy was imported - which is what was being used on that line as written in your code. so the vals= line is equivalent to vals = numpy.norm(np.linspace(14,40,1000)) which meant vals got assigned the value 886.25397758173483, and not at all what we wanted. We wanted it to get an array of 1000 numbers: vals = mpl.colors.Normalize(vmin=0, vmax=40)(np.linspace(14,40,1000)) That's where your trouble with newcm were coming from. Here's the complete example again, I've renamed the 'norm' variable to 'rawlins_norm' for clarity. import matplotlib as mpl import matplotlib.pyplot as plt from matplotlib import cm import numpy as np # Make a figure and axes with dimensions as desired. fig = plt.figure(figsize=(8,3)) ax1 = plt.subplot(2,1,1) ax2 = plt.subplot(2,1,2) # Set the colormap and norm to correspond to the data for which # the colorbar will be used. rawlins_norm = mpl.colors.Normalize(vmin=0, vmax=40) # here set colorbar min/max # the right place for vals vals = rawlins_norm(np.linspace(14,40,1000)) newcm = cm.colors.ListedColormap(cm.hot_r(vals)) cb1 = mpl.colorbar.ColorbarBase(ax1, cmap=cm.hot_r, norm=rawlins_norm, orientation='horizontal') cb1.set_label('"percent"') cb2 = mpl.colorbar.ColorbarBase(ax2, cmap=newcm, orientation='horizontal') cb2.set_label("colormap interval 0.0-1.0") plt.subplots_adjust(hspace=.7, bottom=.2) #comment out the next line to see the original (0-40 colormap) ax1.set_xlim(rawlins_norm((14,40))) plt.show() best, -- Paul Ivanov 314 address only used for lists, off-list direct email at: http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7