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
(8) |
2
(14) |
3
(22) |
4
(13) |
5
(11) |
6
(12) |
7
(4) |
8
(6) |
9
(19) |
10
(14) |
11
(16) |
12
(6) |
13
(15) |
14
(6) |
15
(8) |
16
(22) |
17
(17) |
18
(8) |
19
(16) |
20
(19) |
21
(3) |
22
(6) |
23
(18) |
24
(26) |
25
(17) |
26
(13) |
27
(18) |
28
(8) |
29
|
30
(14) |
31
(30) |
|
|
|
|
Pablo Romero wrote: > Eric, > > thanks for all of the help. > > Im going to do what you suggested; find a way to add a very small amount to my '0.0' values, as this should definitely place them in the 'above zero boundary' bin. > Z[Z==0] = 0.1 That's all you need, it appears. Eric
Eric, thanks for all of the help. Im going to do what you suggested; find a way to add a very small amount to my '0.0' values, as this should definitely place them in the 'above zero boundary' bin. Thanks again, P.Romero ---------------------------------------- > Date: 2009年3月16日 08:58:23 -1000 > From: ef...@ha... > Subject: Re: [Matplotlib-users] FW: basemap.contourf, colormap, extend='none', & levels array question > To: rom...@ho... > CC: mat...@li... > > Pablo Romero wrote: >> Eric, >> For your reference, Im sending you a link to the python-grads interface files. > > Thank you. > > I am coming to the conclusion that you were mostly right early on. I > suspect that whether points landing on a contour boundary end up treated > as above or below is not uniquely defined by the algorithm, but depends > on the context. In my extremely simple examples, zero-values seem to > land in the above-zero bin, but with your array it is the opposite--at > least for the obvious large land masses. > > This brings us back to the workaround I suggested earlier; add a small > number to your points at zero to boost them up into the first bin. > > Something like this could be done within the contour code, with the > option of allowing one to specify that on-the-boundary is above, or that > it is below. I don't think I would want to do this data-fudging > automatically--partly because it would incur a speed penalty, partly > because it really is fudging--but maybe it should be added as an option. > I'm not enthusiastic about it. I would prefer to simply add a warning > to the documentation and leave the fudging to the user. > > Eric > >> >> http://downloads.sourceforge.net/opengrads/pygrads-1.1.0.tar.gz >> >> It wont function unless you have grads available, but perhaps it might help to take a look at how the python code is creating the GrADS masked arrays? >> >> Pablo >> >> ---------------------------------------- >>> Date: 2009年3月16日 07:25:10 -1000 >>> From: ef...@ha... >>> Subject: Re: [Matplotlib-users] FW: basemap.contourf, colormap, extend='none', & levels array question >>> To: rom...@ho... >>> CC: mat...@li... >>> >>> Pablo Romero wrote: >>>> Eric, >>>> I've uploaded the file. >>>> The only thing I should mention is that my 'X' and 'Y' arrays are not masked arrays, they are 2d arrays that I created using the meshgrid function. >>>> >>>> I ended up doing this >>>> >>>> Xnp=np.array(X) >>>> Ynp=np.array(Y) >>>> >>>> which probably wasnt necessary.. >>>> >>>> Let me know if the file worked for you. >>> I got the file and I see the problem. It may take a while for me to >>> find the bug. >>> >>> Eric >> _________________________________________________________________ >> Hotmail® is up to 70% faster. Now good news travels really fast. >> http://windowslive.com/online/hotmail?ocid=TXT_TAGLM_WL_HM_70faster_032009 > _________________________________________________________________ Windows LiveTM Groups: Create an online spot for your favorite groups to meet. http://windowslive.com/online/groups?ocid=TXT_TAGLM_WL_groups_032009
Pablo Romero wrote: > Eric, > For your reference, Im sending you a link to the python-grads interface files. Thank you. I am coming to the conclusion that you were mostly right early on. I suspect that whether points landing on a contour boundary end up treated as above or below is not uniquely defined by the algorithm, but depends on the context. In my extremely simple examples, zero-values seem to land in the above-zero bin, but with your array it is the opposite--at least for the obvious large land masses. This brings us back to the workaround I suggested earlier; add a small number to your points at zero to boost them up into the first bin. Something like this could be done within the contour code, with the option of allowing one to specify that on-the-boundary is above, or that it is below. I don't think I would want to do this data-fudging automatically--partly because it would incur a speed penalty, partly because it really is fudging--but maybe it should be added as an option. I'm not enthusiastic about it. I would prefer to simply add a warning to the documentation and leave the fudging to the user. Eric > > http://downloads.sourceforge.net/opengrads/pygrads-1.1.0.tar.gz > > It wont function unless you have grads available, but perhaps it might help to take a look at how the python code is creating the GrADS masked arrays? > > Pablo > > ---------------------------------------- >> Date: 2009年3月16日 07:25:10 -1000 >> From: ef...@ha... >> Subject: Re: [Matplotlib-users] FW: basemap.contourf, colormap, extend='none', & levels array question >> To: rom...@ho... >> CC: mat...@li... >> >> Pablo Romero wrote: >>> Eric, >>> I've uploaded the file. >>> The only thing I should mention is that my 'X' and 'Y' arrays are not masked arrays, they are 2d arrays that I created using the meshgrid function. >>> >>> I ended up doing this >>> >>> Xnp=np.array(X) >>> Ynp=np.array(Y) >>> >>> which probably wasnt necessary.. >>> >>> Let me know if the file worked for you. >> I got the file and I see the problem. It may take a while for me to >> find the bug. >> >> Eric > _________________________________________________________________ > Hotmail® is up to 70% faster. Now good news travels really fast. > http://windowslive.com/online/hotmail?ocid=TXT_TAGLM_WL_HM_70faster_032009
I need a reference to a "How to..." (or a sample code) to changing the color (Default or otherwise) of the Canvas, when plotting with matplotlib, using Python 2.5 on Windows. -- View this message in context: http://www.nabble.com/pylab-matplotlib-canvas-background-color-change...-tp22541479p22541479.html Sent from the matplotlib - users mailing list archive at Nabble.com.
Eric, For your reference, Im sending you a link to the python-grads interface files. http://downloads.sourceforge.net/opengrads/pygrads-1.1.0.tar.gz It wont function unless you have grads available, but perhaps it might help to take a look at how the python code is creating the GrADS masked arrays? Pablo ---------------------------------------- > Date: 2009年3月16日 07:25:10 -1000 > From: ef...@ha... > Subject: Re: [Matplotlib-users] FW: basemap.contourf, colormap, extend='none', & levels array question > To: rom...@ho... > CC: mat...@li... > > Pablo Romero wrote: >> Eric, >> I've uploaded the file. >> The only thing I should mention is that my 'X' and 'Y' arrays are not masked arrays, they are 2d arrays that I created using the meshgrid function. >> >> I ended up doing this >> >> Xnp=np.array(X) >> Ynp=np.array(Y) >> >> which probably wasnt necessary.. >> >> Let me know if the file worked for you. > > I got the file and I see the problem. It may take a while for me to > find the bug. > > Eric _________________________________________________________________ Hotmail® is up to 70% faster. Now good news travels really fast. http://windowslive.com/online/hotmail?ocid=TXT_TAGLM_WL_HM_70faster_032009
Pablo Romero wrote: > Eric, > I've uploaded the file. > The only thing I should mention is that my 'X' and 'Y' arrays are not masked arrays, they are 2d arrays that I created using the meshgrid function. > > I ended up doing this > > Xnp=np.array(X) > Ynp=np.array(Y) > > which probably wasnt necessary.. > > Let me know if the file worked for you. I got the file and I see the problem. It may take a while for me to find the bug. Eric
Eric, I've uploaded the file. The only thing I should mention is that my 'X' and 'Y' arrays are not masked arrays, they are 2d arrays that I created using the meshgrid function. I ended up doing this Xnp=np.array(X) Ynp=np.array(Y) which probably wasnt necessary.. Let me know if the file worked for you. Pablo ---------------------------------------- > Date: 2009年3月15日 21:14:01 -1000 > From: ef...@ha... > Subject: Re: [Matplotlib-users] FW: basemap.contourf, colormap, extend='none', & levels array question > To: rom...@ho... > CC: mat...@li... > > Pablo Romero wrote: >> Eric, >> Its Still not working, still getting white/empty areas where Z=0.0 >> Here's my ipython output: >> >> [6] ga-> Znp=np.array(Z.filled()) >> [7] ga-> Znp >> Out[7]: >> array([[ 0. , 0. , 0. , ..., 0. , >> 0. , 0. ], >> [ 0. , 0. , 0. , ..., 0. , >> 0. , 0. ], >> [ 0. , 0. , 0. , ..., 0. , >> 0. , 0. ], >> ..., >> [ 1.023 , 1.551 , 2.5079999 , ..., 0.72600001, >> 0.85799998, 1.023 ], >> [ 1.58399999, 1.74899995, 1.9799999 , ..., 0.92400002, >> 1.41899991, 1.58399999], >> [ 0. , 0. , 0. , ..., 0. , >> 0. , 0. ]]) >> [8] ga-> Lv=(0,1,3,5,6,7,8,9,10,12,14,16,18,20,25,30,35,40,50,75) >> [9] ga-> norm = mpl.colors.BoundaryNorm(Lv,256) >> [10] plt.contourf(Znp, Lv, norm=norm) >> Out[10]: >> [11] Znp[0,0] >> Out[11]: 0.0 >> [12] Znp[-1,0] >> Out[12]: 0.0 >> [13] Znp[1,0] >> Out[13]: 0.0 >> [14] Znp[0,1] >> Out[14]: 0.0 >> [15] Znp[0,-1] >> Out[15]: 0.0 > > You missed the [-1,-1] corner. I thought at least one corner would be > non-zero, but maybe not. At this point, it doesn't matter. > >> >> This is very frustrating. :( >> >> Is there anything else Im missing here? >> anything else I can try? > > Now I am wondering whether there is any difference between your > numpy/matplotlib installation and mine that is making this > difference--although that really does not make any sense, either. But > let's check it. Please use the same method as above to make Xnp and > Ynp, and then use np.savez to write out a file with Xnp, Ynp, and Znp: > > np.savez('XYZ.npz', Xnp=Xnp, Ynp=Ynp, Znp=Znp) > > and ftp XYZ.npz to ftp://currents.soest.hawaii.edu/pub/incoming. Then I > can easily try to reproduce exactly what you are doing, and we will see > if I get the same result, or a different one. > > >> >> Im beginning to think that negative/"less than zero" values are actually being plotted in those land areas, even though my array is only showing zeros, '0.0'. > > I don't see how this could be. > >> >> Is there any way I can plot the output in a grid format? >> i.e. print the text value of each point in the array at each point on the plot? >> This way, I can see if a '0.0' value is really being plotted in those white/blank areas. >> > Not trivially; among other things, I think you have too many points. And > you have already verified that the values print as 0.0. I am sure they > really are 0.0. > >> Or, is there another/better way to keep diagnosing the problem? >> > > I can't think of anything now other than letting me try it on my system, > as suggested above. > > You might also see what happens with a workaround: > > Znp0 = Znp.copy() > Znp0[Znp==0] = 0.1 > > Then try plotting Znp0. > > Eric _________________________________________________________________ Windows LiveTM Groups: Create an online spot for your favorite groups to meet. http://windowslive.com/online/groups?ocid=TXT_TAGLM_WL_groups_032009
Pablo Romero wrote: > Eric, > Its Still not working, still getting white/empty areas where Z=0.0 > Here's my ipython output: > > [6] ga-> Znp=np.array(Z.filled()) > [7] ga-> Znp > Out[7]: > array([[ 0. , 0. , 0. , ..., 0. , > 0. , 0. ], > [ 0. , 0. , 0. , ..., 0. , > 0. , 0. ], > [ 0. , 0. , 0. , ..., 0. , > 0. , 0. ], > ..., > [ 1.023 , 1.551 , 2.5079999 , ..., 0.72600001, > 0.85799998, 1.023 ], > [ 1.58399999, 1.74899995, 1.9799999 , ..., 0.92400002, > 1.41899991, 1.58399999], > [ 0. , 0. , 0. , ..., 0. , > 0. , 0. ]]) > [8] ga-> Lv=(0,1,3,5,6,7,8,9,10,12,14,16,18,20,25,30,35,40,50,75) > [9] ga-> norm = mpl.colors.BoundaryNorm(Lv,256) > [10] plt.contourf(Znp, Lv, norm=norm) > Out[10]: > [11] Znp[0,0] > Out[11]: 0.0 > [12] Znp[-1,0] > Out[12]: 0.0 > [13] Znp[1,0] > Out[13]: 0.0 > [14] Znp[0,1] > Out[14]: 0.0 > [15] Znp[0,-1] > Out[15]: 0.0 You missed the [-1,-1] corner. I thought at least one corner would be non-zero, but maybe not. At this point, it doesn't matter. > > This is very frustrating. :( > > Is there anything else Im missing here? > anything else I can try? Now I am wondering whether there is any difference between your numpy/matplotlib installation and mine that is making this difference--although that really does not make any sense, either. But let's check it. Please use the same method as above to make Xnp and Ynp, and then use np.savez to write out a file with Xnp, Ynp, and Znp: np.savez('XYZ.npz', Xnp=Xnp, Ynp=Ynp, Znp=Znp) and ftp XYZ.npz to ftp://currents.soest.hawaii.edu/pub/incoming. Then I can easily try to reproduce exactly what you are doing, and we will see if I get the same result, or a different one. > > Im beginning to think that negative/"less than zero" values are actually being plotted in those land areas, even though my array is only showing zeros, '0.0'. I don't see how this could be. > > Is there any way I can plot the output in a grid format? > i.e. print the text value of each point in the array at each point on the plot? > This way, I can see if a '0.0' value is really being plotted in those white/blank areas. > Not trivially; among other things, I think you have too many points. And you have already verified that the values print as 0.0. I am sure they really are 0.0. > Or, is there another/better way to keep diagnosing the problem? > I can't think of anything now other than letting me try it on my system, as suggested above. You might also see what happens with a workaround: Znp0 = Znp.copy() Znp0[Znp==0] = 0.1 Then try plotting Znp0. Eric
Hi, When using the macosx backend and the pan/zoom tool, I cannot zoom in/out with the right mouse button. The left mouse button does the panning as usual. This only seems to happen with the macosx backend. Other backends (GTKAgg, WXAgg) work fine. I am using ipython [-pylab] and matplotlib from svn, revision 6979. Is this bug know? I couldn't find a reference to it. Cheers, Tiago
Eric, Its Still not working, still getting white/empty areas where Z=0.0 Here's my ipython output: [6] ga-> Znp=np.array(Z.filled()) [7] ga-> Znp Out[7]: array([[ 0. , 0. , 0. , ..., 0. , 0. , 0. ], [ 0. , 0. , 0. , ..., 0. , 0. , 0. ], [ 0. , 0. , 0. , ..., 0. , 0. , 0. ], ..., [ 1.023 , 1.551 , 2.5079999 , ..., 0.72600001, 0.85799998, 1.023 ], [ 1.58399999, 1.74899995, 1.9799999 , ..., 0.92400002, 1.41899991, 1.58399999], [ 0. , 0. , 0. , ..., 0. , 0. , 0. ]]) [8] ga-> Lv=(0,1,3,5,6,7,8,9,10,12,14,16,18,20,25,30,35,40,50,75) [9] ga-> norm = mpl.colors.BoundaryNorm(Lv,256) [10] plt.contourf(Znp, Lv, norm=norm) Out[10]: [11] Znp[0,0] Out[11]: 0.0 [12] Znp[-1,0] Out[12]: 0.0 [13] Znp[1,0] Out[13]: 0.0 [14] Znp[0,1] Out[14]: 0.0 [15] Znp[0,-1] Out[15]: 0.0 This is very frustrating. :( Is there anything else Im missing here? anything else I can try? Im beginning to think that negative/"less than zero" values are actually being plotted in those land areas, even though my array is only showing zeros, '0.0'. Is there any way I can plot the output in a grid format? i.e. print the text value of each point in the array at each point on the plot? This way, I can see if a '0.0' value is really being plotted in those white/blank areas. Or, is there another/better way to keep diagnosing the problem? P.Romero ---------------------------------------- > Date: 2009年3月15日 19:38:36 -1000 > From: ef...@ha... > Subject: Re: [Matplotlib-users] FW: basemap.contourf, colormap, extend='none', & levels array question > To: rom...@ho... > CC: mat...@li... > > Pablo Romero wrote: >> Eric, >> >> the GrADS interface is called 'pygrads'. >> it was developed by arlindo da silva of the 'opengrads' project; a project aimed at extending & enhancing the capabilities of grads by adding 'extensions' to the core grads engine. >> >> Many users are switching to plotting with pygrads due to the fact that matplotlib is a much richer, more powerful, more mature/extensive plotting environment. >> >> So, GrADS users can manipulate gridded data in grads, export through pygrads, and create nicer/more elaborate plots using matplotlib ;) >> >> http://opengrads.org/wiki/index.php?title=Python_Interface_to_GrADS >> >> >> >> as for the solution you offered, I tried doing the following: >> >> cs = m.contourf(X,Y,Z.filled(),Lv,norm=norm,cmap=plt.cm.jet) >> >> but I still got a plot with the '0.0' (land) areas plotted as 'white'/missing?. >> >> Does it matter that the output I provided from the "Z.mask" command showed all 'false' for the mask array? > > All this is strange again. I did not expect Z.mask to be all False. > > Try > > import numpy as np > Znp = np.array(Z.filled(0.0)) > > and then contour that instead of Z. If that doesn't work, then check > the corner values of Znp: > > Znp[0,0], Znp[-1,0] etc. > > Eric _________________________________________________________________ Windows LiveTM Contacts: Organize your contact list. http://windowslive.com/connect/post/marcusatmicrosoft.spaces.live.com-Blog-cns!503D1D86EBB2B53C!2285.entry?ocid=TXT_TAGLM_WL_UGC_Contacts_032009
Pablo Romero wrote: > Eric, > > the GrADS interface is called 'pygrads'. > it was developed by arlindo da silva of the 'opengrads' project; a project aimed at extending & enhancing the capabilities of grads by adding 'extensions' to the core grads engine. > > Many users are switching to plotting with pygrads due to the fact that matplotlib is a much richer, more powerful, more mature/extensive plotting environment. > > So, GrADS users can manipulate gridded data in grads, export through pygrads, and create nicer/more elaborate plots using matplotlib ;) > > http://opengrads.org/wiki/index.php?title=Python_Interface_to_GrADS > > > > as for the solution you offered, I tried doing the following: > > cs = m.contourf(X,Y,Z.filled(),Lv,norm=norm,cmap=plt.cm.jet) > > but I still got a plot with the '0.0' (land) areas plotted as 'white'/missing?. > > Does it matter that the output I provided from the "Z.mask" command showed all 'false' for the mask array? All this is strange again. I did not expect Z.mask to be all False. Try import numpy as np Znp = np.array(Z.filled(0.0)) and then contour that instead of Z. If that doesn't work, then check the corner values of Znp: Znp[0,0], Znp[-1,0] etc. Eric
Hi all, [ apologies for the semi-spam, I'll keep this brief and expect all replies off-list ] IPython is a project that many of you on this list are likely to use in your daily work, either directly or indirectly (if you've embedded it or used it as a component of some other system). I would simply like to ask you, if IPython has been significantly useful for a project you use, lead, develop, etc., to let me know. For legal/professional reasons, I need to gather information about who has found IPython to be of value. I started IPython as a toy 'afternoon hack' in late 2001, and today it continues to grow, as the nicely summarized Ohloh stats show: https://www.ohloh.net/p/ipython (obviously, this is now the result of the work of many, not just myself, as is true of any healthy open source project as it grows). But I have never systematically tracked its impact, and now I need to do so. So, if you have used IPython and it has made a significant contribution to your project, work, research, company, whatever, I'd be very grateful if you let me know. A short paragraph on what this benefit has been is all I ask. Once I gather any information I get, I would contact directly some of the responders to ask for your authorization before quoting you. I should stress that any information you give me will only go in a documentation packet in support of my legal/residency process here in the USA (think of it as an oversized, obnoxiously detailed CV that goes beyond just publications and regular academic information). To keep traffic off this list, please send your replies directly to me, either at this address or my regular work one: Fer...@be... In advance, many thanks to anyone willing to reply. I've never asked for anything in return for working on IPython and the ecosystem of scientific Python tools, but this is actually very important, so any information you can provide me will be very useful. Best regards, Fernando Perez.
Eric, the GrADS interface is called 'pygrads'. it was developed by arlindo da silva of the 'opengrads' project; a project aimed at extending & enhancing the capabilities of grads by adding 'extensions' to the core grads engine. Many users are switching to plotting with pygrads due to the fact that matplotlib is a much richer, more powerful, more mature/extensive plotting environment. So, GrADS users can manipulate gridded data in grads, export through pygrads, and create nicer/more elaborate plots using matplotlib ;) http://opengrads.org/wiki/index.php?title=Python_Interface_to_GrADS as for the solution you offered, I tried doing the following: cs = m.contourf(X,Y,Z.filled(),Lv,norm=norm,cmap=plt.cm.jet) but I still got a plot with the '0.0' (land) areas plotted as 'white'/missing?. Does it matter that the output I provided from the "Z.mask" command showed all 'false' for the mask array? Is there any other info about the 'Z' grads-masked array that I can provide that might help figure out what is going wrong? Pablo ---------------------------------------- > Date: 2009年3月15日 18:01:08 -1000 > From: ef...@ha... > Subject: Re: [Matplotlib-users] FW: basemap.contourf, colormap, extend='none', & levels array question > To: rom...@ho... > CC: mat...@li... > > Pablo Romero wrote: >> it appears to be a masked array, but a "customized" one, that's being created from the interface to the external program Im working with (application named GrADS). here's some more info... >> > > Aha, very interesting! I know about grads but don't use it, and I did > not know about the python interface. > > Out of curiosity, why are you using the grads data interface but not the > grads plotting? > >> [7] ga-> Z? >> Type: GaField >> Base Class: >> String Form: >> [[0.0 0.0 0.0 ..., 0.0 0.0 0.0] >> [0.0 0.0 0.0 ..., 0.0 0.0 0.0] >> [0.0 0.0 0.0 ..., 0.0 0.0 0.0] >> 1.97999989986 ..., 0.924000024796 >> 1.41899991035 1.58399999142] >> [0.0 0.0 0.0 ..., 0.0 0.0 0.0]] >> Namespace: Interactive >> Length: 311 >> File: /usr/lib/python2.5/site-packages/grads/numtypes.py >> Docstring: >> This is GraDS version of a n-dimensional array: a masked array with >> a *grid* containing coordinate/dimension information attached to it. >> As a MaskedArray, GaField objects may possibly have masked values. >> Masked values of 1 exclude the corresponding element from any >> computation. >> Construction: >> x = GaField (data, name=None, Grid=None, >> dtype=None, copy=True, order=False, >> mask = nomask, fill_value=None) >> If copy=False, every effort is made not to copy the data: >> If data is a MaskedArray, and argument mask=nomask, >> then the candidate data is data.data and the >> mask used is data.mask. If data is a numeric array, >> it is used as the candidate raw data. >> If dtype is not None and >> is != data.dtype.char then a data copy is required. >> Otherwise, the candidate is used. >> If a data copy is required, raw data stored is the result of: >> numeric.array(data, dtype=dtype.char, copy=copy) >> If mask is nomask there are no masked values. Otherwise mask must >> be convertible to an array of booleans with the same shape as x. >> fill_value is used to fill in masked values when necessary, >> such as when printing and in method/function filled(). >> The fill_value is not used for computation within this module. >> >> >> [8] ga-> Z.mask >> Out[8]: >> array([[False, False, False, ..., False, False, False], >> [False, False, False, ..., False, False, False], >> [False, False, False, ..., False, False, False], >> ..., >> [False, False, False, ..., False, False, False], >> [False, False, False, ..., False, False, False], >> [False, False, False, ..., False, False, False]], dtype=bool) >> >> >> [12] ga-> np.linalg.norm([Z[0,0], Z[0,-1], Z[-1,0], Z[-1,-1]]) >> Out[12]: 0.0 > > > What I meant was the BoundaryNorm instance "norm" that you are using to > contour. But that's OK; we don't need that diagnostic now. > > The mystery is solved; the 0 values in your Z array are not really 0, > they are masked, and contourf is handling them correctly. 0.0 is just > the fill value. If you want that to be the *real* value, then instead of > using Z as the argument to your contourf call, use Z.filled(). > > Eric _________________________________________________________________ Windows LiveTM Groups: Create an online spot for your favorite groups to meet. http://windowslive.com/online/groups?ocid=TXT_TAGLM_WL_groups_032009
Pablo Romero wrote: > it appears to be a masked array, but a "customized" one, that's being created from the interface to the external program Im working with (application named GrADS). here's some more info... > Aha, very interesting! I know about grads but don't use it, and I did not know about the python interface. Out of curiosity, why are you using the grads data interface but not the grads plotting? > [7] ga-> Z? > Type: GaField > Base Class: > String Form: > [[0.0 0.0 0.0 ..., 0.0 0.0 0.0] > [0.0 0.0 0.0 ..., 0.0 0.0 0.0] > [0.0 0.0 0.0 ..., 0.0 0.0 0.0] > 1.97999989986 ..., 0.924000024796 > 1.41899991035 1.58399999142] > [0.0 0.0 0.0 ..., 0.0 0.0 0.0]] > Namespace: Interactive > Length: 311 > File: /usr/lib/python2.5/site-packages/grads/numtypes.py > Docstring: > This is GraDS version of a n-dimensional array: a masked array with > a *grid* containing coordinate/dimension information attached to it. > As a MaskedArray, GaField objects may possibly have masked values. > Masked values of 1 exclude the corresponding element from any > computation. > Construction: > x = GaField (data, name=None, Grid=None, > dtype=None, copy=True, order=False, > mask = nomask, fill_value=None) > If copy=False, every effort is made not to copy the data: > If data is a MaskedArray, and argument mask=nomask, > then the candidate data is data.data and the > mask used is data.mask. If data is a numeric array, > it is used as the candidate raw data. > If dtype is not None and > is != data.dtype.char then a data copy is required. > Otherwise, the candidate is used. > If a data copy is required, raw data stored is the result of: > numeric.array(data, dtype=dtype.char, copy=copy) > If mask is nomask there are no masked values. Otherwise mask must > be convertible to an array of booleans with the same shape as x. > fill_value is used to fill in masked values when necessary, > such as when printing and in method/function filled(). > The fill_value is not used for computation within this module. > > > [8] ga-> Z.mask > Out[8]: > array([[False, False, False, ..., False, False, False], > [False, False, False, ..., False, False, False], > [False, False, False, ..., False, False, False], > ..., > [False, False, False, ..., False, False, False], > [False, False, False, ..., False, False, False], > [False, False, False, ..., False, False, False]], dtype=bool) > > > [12] ga-> np.linalg.norm([Z[0,0], Z[0,-1], Z[-1,0], Z[-1,-1]]) > Out[12]: 0.0 What I meant was the BoundaryNorm instance "norm" that you are using to contour. But that's OK; we don't need that diagnostic now. The mystery is solved; the 0 values in your Z array are not really 0, they are masked, and contourf is handling them correctly. 0.0 is just the fill value. If you want that to be the *real* value, then instead of using Z as the argument to your contourf call, use Z.filled(). Eric
it appears to be a masked array, but a "customized" one, that's being created from the interface to the external program Im working with (application named GrADS). here's some more info... [7] ga-> Z? Type: GaField Base Class: String Form: [[0.0 0.0 0.0 ..., 0.0 0.0 0.0] [0.0 0.0 0.0 ..., 0.0 0.0 0.0] [0.0 0.0 0.0 ..., 0.0 0.0 0.0] 1.97999989986 ..., 0.924000024796 1.41899991035 1.58399999142] [0.0 0.0 0.0 ..., 0.0 0.0 0.0]] Namespace: Interactive Length: 311 File: /usr/lib/python2.5/site-packages/grads/numtypes.py Docstring: This is GraDS version of a n-dimensional array: a masked array with a *grid* containing coordinate/dimension information attached to it. As a MaskedArray, GaField objects may possibly have masked values. Masked values of 1 exclude the corresponding element from any computation. Construction: x = GaField (data, name=None, Grid=None, dtype=None, copy=True, order=False, mask = nomask, fill_value=None) If copy=False, every effort is made not to copy the data: If data is a MaskedArray, and argument mask=nomask, then the candidate data is data.data and the mask used is data.mask. If data is a numeric array, it is used as the candidate raw data. If dtype is not None and is != data.dtype.char then a data copy is required. Otherwise, the candidate is used. If a data copy is required, raw data stored is the result of: numeric.array(data, dtype=dtype.char, copy=copy) If mask is nomask there are no masked values. Otherwise mask must be convertible to an array of booleans with the same shape as x. fill_value is used to fill in masked values when necessary, such as when printing and in method/function filled(). The fill_value is not used for computation within this module. [8] ga-> Z.mask Out[8]: array([[False, False, False, ..., False, False, False], [False, False, False, ..., False, False, False], [False, False, False, ..., False, False, False], ..., [False, False, False, ..., False, False, False], [False, False, False, ..., False, False, False], [False, False, False, ..., False, False, False]], dtype=bool) [12] ga-> np.linalg.norm([Z[0,0], Z[0,-1], Z[-1,0], Z[-1,-1]]) Out[12]: 0.0 what other info should I provide? Pablo ---------------------------------------- > Date: 2009年3月15日 17:38:32 -1000 > From: ef...@ha... > Subject: Re: [Matplotlib-users] FW: basemap.contourf, colormap, extend='none', & levels array question > To: rom...@ho... > CC: mat...@li... > > >> >> What is the result from typing >> >> type(Z) >> norm([Z[-1,0]]) > > Actually, I don't know how your data are arranged, so try all 4 corners: > > norm([Z[0,0], Z[0,-1], Z[-1,0], Z[-1,-1]]) > > Eric _________________________________________________________________ Windows LiveTM: Life without walls. http://windowslive.com/explore?ocid=TXT_TAGLM_WL_allup_1a_explore_032009
> > What is the result from typing > > type(Z) > norm([Z[-1,0]]) Actually, I don't know how your data are arranged, so try all 4 corners: norm([Z[0,0], Z[0,-1], Z[-1,0], Z[-1,-1]]) Eric
Pablo Romero wrote: > > Im experiencing unexpected behavior with contourf. > Im trying to plot float values of '0.0', while also using the following levels array with contourf(): > > Lv=(0,1,3,5,6,7,8,9,10,12,14,16,18,20,25,30,35,40,50,75) > > I've attached a sample image of the output. > the areas in white are contours where the plot values are exactly '0.0'. The land areas, right? In a simple test, I don't see what you are describing: In [1]:Lv=(0,1,3,5,6,7,8,9,10,12,14,16,18,20,25,30,35,40,50,75) In [2]:norm = mpl.colors.BoundaryNorm(Lv,256) In [4]:norm([0.0]) Out[4]: masked_array(data = [0], mask = [False], fill_value = 999999) In [5]:z = linspace(0.0, 19.0, 20).reshape(4,5) In [6]:z Out[6]: array([[ 0., 1., 2., 3., 4.], [ 5., 6., 7., 8., 9.], [ 10., 11., 12., 13., 14.], [ 15., 16., 17., 18., 19.]]) In [7]:contourf(z, norm=norm) Out[7]:<matplotlib.contour.ContourSet instance at 0x9eaadac> In [8]:contourf(z, Lv, norm=norm) Out[8]:<matplotlib.contour.ContourSet instance at 0xa1ca98c> 0.0 is getting mapped to 0 by the norm, and that is used as an index to select the first cmap color, the darkest blue. Is your Z an ndarray or is it a masked array? What you describe is consistent with the 0 values actually being masked, so they are not being contoured at all--except that contourf has a bug with internal masked regions so that they don't always get left unfilled. In the example above, compare with In [15]:figure() Out[15]:<matplotlib.figure.Figure object at 0xa3879cc> In [16]:contourf(ma.masked_less_equal(z, 0.0), Lv, norm=norm) Out[16]:<matplotlib.contour.ContourSet instance at 0xa38790c> Now, the problem with this hypothesis is that printing the masked array does *not* show the 0.0 value: In [14]:print ma.masked_less_equal(z, 0.0) [[-- 1.0 2.0 3.0 4.0] [5.0 6.0 7.0 8.0 9.0] [10.0 11.0 12.0 13.0 14.0] [15.0 16.0 17.0 18.0 19.0]] so I don't understand what is going on in your case. What is the result from typing type(Z) norm([Z[-1,0]]) in ipython (after generating Z, of course)? > > I am not using the "extend='min|both'" in my contourf() function call. > If I use the "extend='min|both'" option, it will plot the '0.0' plot values using the color of the 1st-2nd level (blue). However, for my application, I DO NOT want to use the 'extend' option; I want my contour & colorbar levels to start at 0. > We should figure out what the problem really is. If the 0.0 (land) values are being treated as below the 0 boundary, then you should be able to control their color like this: cmap = cm.jet cmap.set_under(cmap(0)) # to make it the same as the 0-1 color contourf(X, Y, Z, Lv, norm=norm, cmap=cmap) > So, in theory,the '0.0' float values *should* be considered to be at the '0->1' range within my levels array, correct? > Yes, and as noted above, when I test it, it is. Eric > Im not sure how to create an example that can reproduce my data with '0.0' float values. > this is more/less the basis of the code I used to create the attached plot image: > > # assume Z is my dataset > > Z=create_my_data() > > # setup basemap instance > # I call contourf from the basemap instance > # but the problem still exists even when > # contourf is called from pyplot instance > > m=basemap(...) > ... > > print "Z: ",Z > > # this prints the following > # this is the best I can do to demonstrate what my data in 'Z' looks like > # > # Z: [[11.9459991455 11.9789991379 12.0119991302 ..., 8.51399993896 > # 8.05200004578 7.55699968338] > # [12.375 12.4079999924 12.4409999847 ..., 9.00899982452 8.57999992371 > # 8.08500003815] > # [12.8039999008 12.8369998932 12.8699998856 ..., 9.43799972534 > # 9.07499980927 8.64599990845] > # ..., > # [0.0 0.0 0.0 ..., 4.52099990845 5.2469997406 5.90700006485] > # [0.0 0.0 0.0 ..., 6.13800001144 6.33599996567 6.73199987411] > # [0.0 0.0 0.0 ..., 4.98299980164 5.64299964905 6.26999998093]] > > # my plotting code > > Lv=(0,1,3,5,6,7,8,9,10,12,14,16,18,20,25,30,35,40,50,75) > norm = mpl.colors.BoundaryNorm(Lv,256) > cs = m.contourf(X,Y,Z,Lv,norm=norm,cmap=cm.jet) > plt.colorbar(cs) > plt.show() > > > I believe that matplotlib is having issues with comparing the "zero"- value level & '0.0' array values in my plot; it seems like its considering the '0.0' values to be 'less than zero' and thus not plotting them within the 'zero-through-one' level of my levels array. It seems as though its plotting these '0.0' values using the color assigned to the cmap's "set_under" property (anything below the 1st layer gets plotted in white or the 'set_under' color). is this correct? > > Ive tried setting the first value in my levels array to '0.0' instead of just '0', but the results were the same. > > Is this a bug; the fact that the '0.0' are not being associated with the '0' level? > > Please help, > P.Romero
Im experiencing unexpected behavior with contourf. Im trying to plot float values of '0.0', while also using the following levels array with contourf(): Lv=(0,1,3,5,6,7,8,9,10,12,14,16,18,20,25,30,35,40,50,75) I've attached a sample image of the output. the areas in white are contours where the plot values are exactly '0.0'. I am not using the "extend='min|both'" in my contourf() function call. If I use the "extend='min|both'" option, it will plot the '0.0' plot values using the color of the 1st-2nd level (blue). However, for my application, I DO NOT want to use the 'extend' option; I want my contour & colorbar levels to start at 0. So, in theory,the '0.0' float values *should* be considered to be at the '0->1' range within my levels array, correct? Im not sure how to create an example that can reproduce my data with '0.0' float values. this is more/less the basis of the code I used to create the attached plot image: # assume Z is my dataset Z=create_my_data() # setup basemap instance # I call contourf from the basemap instance # but the problem still exists even when # contourf is called from pyplot instance m=basemap(...) ... print "Z: ",Z # this prints the following # this is the best I can do to demonstrate what my data in 'Z' looks like # # Z: [[11.9459991455 11.9789991379 12.0119991302 ..., 8.51399993896 # 8.05200004578 7.55699968338] # [12.375 12.4079999924 12.4409999847 ..., 9.00899982452 8.57999992371 # 8.08500003815] # [12.8039999008 12.8369998932 12.8699998856 ..., 9.43799972534 # 9.07499980927 8.64599990845] # ..., # [0.0 0.0 0.0 ..., 4.52099990845 5.2469997406 5.90700006485] # [0.0 0.0 0.0 ..., 6.13800001144 6.33599996567 6.73199987411] # [0.0 0.0 0.0 ..., 4.98299980164 5.64299964905 6.26999998093]] # my plotting code Lv=(0,1,3,5,6,7,8,9,10,12,14,16,18,20,25,30,35,40,50,75) norm = mpl.colors.BoundaryNorm(Lv,256) cs = m.contourf(X,Y,Z,Lv,norm=norm,cmap=cm.jet) plt.colorbar(cs) plt.show() I believe that matplotlib is having issues with comparing the "zero"- value level & '0.0' array values in my plot; it seems like its considering the '0.0' values to be 'less than zero' and thus not plotting them within the 'zero-through-one' level of my levels array. It seems as though its plotting these '0.0' values using the color assigned to the cmap's "set_under" property (anything below the 1st layer gets plotted in white or the 'set_under' color). is this correct? Ive tried setting the first value in my levels array to '0.0' instead of just '0', but the results were the same. Is this a bug; the fact that the '0.0' are not being associated with the '0' level? Please help, P.Romero _________________________________________________________________ Windows LiveTM: Life without walls. http://windowslive.com/explore?ocid=TXT_TAGLM_WL_allup_1a_explore_032009
On Sat, Mar 14, 2009 at 8:23 AM, Jeff Whitaker <js...@fa...> wrote: > Timothée Lecomte wrote: > > Jeff Whitaker wrote: > >> Jeff Whitaker wrote: > >>> Timothée Lecomte wrote: > >>>> Dear all, > >>>> > >>>> I am using matplotlib with a great pleasure, and I enjoy its > >>>> capabilities. > >>>> I have recently attended a conference where the invited speaker > >>>> showed great visualizations of arrays from both experiments and > >>>> simulations. His plots were basically looking like those produced > >>>> by imshow, that is a luminance array rendered as a colormap image, > >>>> but with the additionnal use of a shading, which gives a really > >>>> great feeling to the image. You can feel the height of each part of > >>>> the image. > >>>> > >>>> I have tried to find what software could have produced such a plot, > >>>> and found the ReliefPlot function of Mathematica, which has > >>>> precisely this purpose : rendering a colormap image from an array > >>>> with a shading to give the perception of relief. > >>>> > >>>> The documentation and its examples are self-explanatory : > >>>> http://reference.wolfram.com/mathematica/ref/ReliefPlot.html > >>>> (look in particular at the first "neat example" at the bottom of > >>>> that page) > >>>> > >>>> The two "live" demonstrations illustrate this plot style quite well > >>>> too : > >>>> http://demonstrations.wolfram.com/ReliefShadedElevationMap/ > >>>> http://demonstrations.wolfram.com/VoronoiImage/ > >>>> > >>>> So here are my questions : > >>>> Is there a trick to generate an image with such a shading in > >>>> matplotlib ? > >>>> If not, do you know of a python tool that could help ? > >>>> Where could I start if I want to code it myself in matplotlib ? > >>>> > >>>> Thanks for your help. > >>>> > >>>> Best regards, > >>>> > >>>> Timothée Lecomte > >>>> > >>>> > >>> > >>> Timothée: There is nothing built-in, but it would be a nice thing > >>> to have. Here's a proof-of-concept hack that follows the approach > >>> used in the Generic Mapping Tools (explained here > >>> http://www.seismo.ethz.ch/gmt/doc/html/tutorial/node70.html), with > >>> some code borrowed from http://www.langarson.com.au/blog/?p=14. > >>> It's very rough, but if it looks promising to you I can try to > >>> polish it. > >>> > >>> -Jeff > >> > >> Found a bug, here's a fixed version. > >> > >> -Jeff > >> > > Hi Jeff, > > > > Sure it looks promising ! The example you provided is very nice. I > > will try on my own data on Monday, and I'll let you know if it gives a > > good result too. Thank you very much for that very fast hack ! > > > > Best regards, > > > > Timothée > > > > > Timothée: I've added this capability in svn, along with an example > (shading_example.py) to show how to use it. Thanks for suggesting it. > That looks awesome. Very nice work, Jeff. Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma
Pablo Romero wrote: > This is related to a previous question I had about colormaps; > Im looking for a method to evenly split up a colormap into an RGB colors array. > something like: > > def cmap_to_array(cmap,N): > ... > > mycolors=cmap_to_array(cm.jet,20) > lev=np.arange(1,20,1) > cs=contourf(Z,lev,colors=mycolors) > > ... > > where 'mycolors' would be a 20x3 array with RGB values for 20 colors that represent the cm.jet spectrum broken up evenly into 20 colors... > > I believe colors array can contain RGB tuples, something like [[0.2,0.3,1],[0.3,0.5,1], ... ,[1,1,0]] should work. > > However, I dont know how to extract the tuples from an existing colormap. > How can this be done? Pablo, I think that what you want can be handled very simply using the BoundaryNorm as I have suggested earlier. However, it is not hard to generate any number of evenly spaced colors (for use in the "colors" kwarg of contourf). Here is one way to do it: import numpy as np import matplotlib.cm as cm def make_N_colors(cmap_name, N): cmap = cm.get_cmap(cmap_name, N) return cmap(np.arange(N)) This will return a sequence of RGBA values, actually an Nx4 ndarray. I don't think the inclusion of the 4th column hurts anything, but obviously you can use indexing to remove it if you want to. The last line in the function would change to return cmap(np.arange(N))[:,:-1] cmap_name is a string chosen from the values in cm.datad.keys(). You will want N to be len(lev) - 1. Eric
Please disregard this question, as a solution was found to this problem using the 'BoundaryNorm' function. P.Romero ---------------------------------------- > From: rom...@ho... > To: mat...@li... > Date: 2009年3月15日 13:37:04 -0700 > Subject: [Matplotlib-users] convert colormap to RGB color array > > > This is related to a previous question I had about colormaps; > Im looking for a method to evenly split up a colormap into an RGB colors array. > something like: > > def cmap_to_array(cmap,N): > ... > > mycolors=cmap_to_array(cm.jet,20) > lev=np.arange(1,20,1) > cs=contourf(Z,lev,colors=mycolors) > > ... > > where 'mycolors' would be a 20x3 array with RGB values for 20 colors that represent the cm.jet spectrum broken up evenly into 20 colors... > > I believe colors array can contain RGB tuples, something like [[0.2,0.3,1],[0.3,0.5,1], ... ,[1,1,0]] should work. > > However, I dont know how to extract the tuples from an existing colormap. > How can this be done? > > > Please help... > Thanks, > > P.Romero > _________________________________________________________________ > Windows LiveTM Groups: Create an online spot for your favorite groups to meet. > http://windowslive.com/online/groups?ocid=TXT_TAGLM_WL_groups_032009 > ------------------------------------------------------------------------------ > Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are > powering Web 2.0 with engaging, cross-platform capabilities. Quickly and > easily build your RIAs with Flex Builder, the Eclipse(TM)based development > software that enables intelligent coding and step-through debugging. > Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users _________________________________________________________________ Windows LiveTM Contacts: Organize your contact list. http://windowslive.com/connect/post/marcusatmicrosoft.spaces.live.com-Blog-cns!503D1D86EBB2B53C!2285.entry?ocid=TXT_TAGLM_WL_UGC_Contacts_032009
Eric, the "BoundaryNorm" was what I was looking for. it did exactly what I needed; split the colormap up evenly into discrete colors based on the number of elements in my levels array. Thanks, P.Romero ---------------------------------------- > Date: 2009年3月15日 10:38:22 -1000 > From: ef...@ha... > Subject: Re: [Matplotlib-users] question about levels & colormaps for contour functions > To: rom...@ho...; mat...@li... > > Pablo Romero wrote: >> Eric, >> >> I believe the problem is that my 19 levels are not evenly distributed; >> >> Lv=(1,3,5,6,7,8,9,10,12,14,16,18,20,25,30,35,40,50,75) > > No, I don't think that has much to do with it, unless the problem is > that the colors of some levels are too similar. > > Again, please make a simple, complete, self-contained example, and we > will go from there. > > I think what you want may be something like this: > > levs=[1,3,5,6,7,8,9,10,12,14,16,18,20,25,30,35,40,50,75] > norm = mpl.colors.BoundaryNorm(levs, 256) > z = rand(10,15)*14 # fake data covering only lower levs > contourf(z, levs, norm=norm, cmap=cm.jet, extend='both') > colorbar() > > >> >> the first part of the range starts at 1,3,5, but then includes 6,7,8,9, and then only goes with even numbers..10,12,14,16,18,20...then by 5 up until 35, then jumps by 10...etc. >> >> I know this seems strange, but this was done because Im plotting 'ocean wave heights' and these were decided to be the 'heights of interest' for the project Im working on. >> > > Perfectly reasonable. > >> anyway, what I want is to be able to breakup the 'cm.jet' spectrum evenly based on the # of levels (and not on their values), and spread my levels evenly across the spectrum.... >> >> i.e., I want the first 6-7 levels to be evenly spread from blue to about green acros cm.jet's spectrum, approx. the next 6 levels to be evenly spread across cm.jet's yellow-orange part of the spectrum, and the last few levels to be evenly spread across the reds... >> >> Ideally, Id like to be able to use any colormap, and simply break up its color spectrum evenly, and then assign each distinct color to each level in my levels array. >> >> So, I guess I need a method to programatically, evenly break up cm.jet by the # of levels, create a colors array & pass this array to contourf(colors='mycolorsarray')... >> >> does this make sense? >> >> P.Romero >> >> ---------------------------------------- >>> Date: 2009年3月15日 08:32:32 -1000 >>> From: ef...@ha... >>> Subject: Re: [Matplotlib-users] question about levels & colormaps for contour functions >>> To: rom...@ho... >>> CC: mat...@li... >>> >>> Pablo Romero wrote: >>>> Hi, >>>> >>>> I would like to know how I can pass an array of levels and also a colormap to the contour() function and have the levels span the entire colormap. example... >>>> >>>> if I do the following.... >>>> >>>> >>>> Lv=(1,3,5,6,7,8,9,10,12,14,16,18,20,25,30,35,40,50,75) >>>> >>>> cs=plt.contourf(X,Y,waveheight,Lv,cmap=cm.jet,extend='both') >>>> >>>> >>>> I would expect that contours that are in the higher levels (i.e., levels above value '14' in my levels array) would be plotted with lighter colors in the cm.jet spectrum; the greens, yellows,oranges,reds, etc. >>>> >>>> However, contourf is simply breaking up the lower,"dark blue" half of the cm.jet spectrum into small slices, and spreading all of my levels throughout only the bottom half of cm.jet. >>>> >>> I don't see the problem yet. Here is an attempt to recreate what it >>> sounds like you are describing above (run in ipython -pylab): >>> >>> contourf(rand(10,12), arange(0,5.01,0.2), cmap=cm.jet, extend='both') >>> colorbar() >>> >>> The data are all blue because they are in the 0-1 range, while the >>> levels span the 0-5 range. The colorbar shows that the colormap is >>> covering the latter range, as it should. >>> >>> If you can make a simple self-contained example like this, and then >>> describe the difference between what it does and what you want it to do, >>> we can figure out how to get your desired result. >>> >>> Eric >>> >>> >>> >>> >>> >>>> I followed this tutorial: >>>> http://www.scipy.org/Cookbook/Matplotlib/ColormapTransformations >>>> >>>> that shows how to create a "discrete" colormap, but this also didnt work; the contourf function again simply sliced up the lower, blue colors and spread my all of my layers across the "blues" in my discrete colormap. >>>> >>>> >>>> If I use a colors array instead of a colormap, I can achieve what I want. However, Id like to be able to use a colormap so that I dont have to manually create color arrays everytime that I want to change my colorscheme. >>>> >>>> So, how can I force contour() to spread my levels across THE WHOLE spectrum of a colormap? >>>> >>>> Please help, >>>> >>>> Thanks, >>>> P.Romero >>>> >>>> >>>> _________________________________________________________________ >>>> Express your personality in color! Preview and select themes for Hotmail®. >>>> http://www.windowslive-hotmail.com/LearnMore/personalize.aspx?ocid=TXT_MSGTX_WL_HM_express_032009#colortheme >>>> ------------------------------------------------------------------------------ >>>> Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are >>>> powering Web 2.0 with engaging, cross-platform capabilities. Quickly and >>>> easily build your RIAs with Flex Builder, the Eclipse(TM)based development >>>> software that enables intelligent coding and step-through debugging. >>>> Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com >>>> _______________________________________________ >>>> Matplotlib-users mailing list >>>> Mat...@li... >>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> _________________________________________________________________ >> Windows LiveTM Contacts: Organize your contact list. >> http://windowslive.com/connect/post/marcusatmicrosoft.spaces.live.com-Blog-cns!503D1D86EBB2B53C!2285.entry?ocid=TXT_TAGLM_WL_UGC_Contacts_032009 > _________________________________________________________________ Windows LiveTM Contacts: Organize your contact list. http://windowslive.com/connect/post/marcusatmicrosoft.spaces.live.com-Blog-cns!503D1D86EBB2B53C!2285.entry?ocid=TXT_TAGLM_WL_UGC_Contacts_032009