Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Rightclick on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: Jeremy Conlin <jlconlin@gm...>  20100630 14:40:00

I am trying to plot some data over a mesh using the plot_surface method. However when I plot my data, everything is the same color when I expected to get a nice rainbow of colors as in the example: http://matplotlib.sourceforge.net/examples/mplot3d/surface3d_demo.html I have attached a simple script to show what I did as well as the result. Essentially, I just copied the above demo, but put my own data in. I think the problem arises because I have "holes" in my data, or areas where the data is zero. These zeros throw the scaling off so I tried to eliminate their effect, but this messed everything up. Essentially my question is: how can I get a nice color distribution while at the same time avoid the extreme scaling issues associated with some data being zero (while all the other data is ~16)? Thanks, Jeremy 
From: Benjamin Root <ben.root@ou...>  20100705 02:39:25
Attachments:
Message as HTML

Jeremy, The pcolor function can take a vmin and a vmax parameter if you wish to control the colorscaling. In addition, you can use a special array structure called a "masked array" to have pcolor ignore "special" values. Assuming your data is 'vals': vals_masked = numpy.ma.masked_array(vals, vals == 0.0) Note that depending on your situation, doing an equality with with a floating point value probably isn't very reliable, so be sure to test and modify to suit your needs. 'vals_masked' can then be passed to pcolor instead of vals. I hope this helps, Ben Root On Wed, Jun 30, 2010 at 9:39 AM, Jeremy Conlin <jlconlin@...> wrote: > I am trying to plot some data over a mesh using the plot_surface > method. However when I plot my data, everything is the same color > when I expected to get a nice rainbow of colors as in the example: > http://matplotlib.sourceforge.net/examples/mplot3d/surface3d_demo.html > > I have attached a simple script to show what I did as well as the > result. Essentially, I just copied the above demo, but put my own > data in. I think the problem arises because I have "holes" in my > data, or areas where the data is zero. These zeros throw the scaling > off so I tried to eliminate their effect, but this messed everything > up. > > Essentially my question is: how can I get a nice color distribution > while at the same time avoid the extreme scaling issues associated > with some data being zero (while all the other data is ~16)? > > Thanks, > Jeremy > > >  > This SF.net email is sponsored by Sprint > What will you do first with EVO, the first 4G phone? > Visit sprint.com/first  http://p.sf.net/sfu/sprintcomfirst > _______________________________________________ > Matplotlibusers mailing list > Matplotlibusers@... > https://lists.sourceforge.net/lists/listinfo/matplotlibusers > > 
From: JaeJoon Lee <lee.j.joon@gm...>  20100706 02:57:05

On Wed, Jun 30, 2010 at 10:39 AM, Jeremy Conlin <jlconlin@...> wrote: > Essentially my question is: how can I get a nice color distribution > while at the same time avoid the extreme scaling issues associated > with some data being zero (while all the other data is ~16)? It seems that plot_surface method does have some issue with NaNs. I think it is best if you manually adjust the color range. For example, vmin = np.nanmin(mass) vmax = np.nanmax(mass) ax.plot_surface(X, Y, mass, rstride=1, cstride=1, cmap=cm.jet, vmin=vmin, vmax=vmax) IHTH, JJ 
From: Jeremy Conlin <jlconlin@gm...>  20100708 14:41:34

On Sun, Jul 4, 2010 at 8:38 PM, Benjamin Root <ben.root@...> wrote: > Jeremy, > > The pcolor function can take a vmin and a vmax parameter if you wish to > control the colorscaling. In addition, you can use a special array > structure called a "masked array" to have pcolor ignore "special" values. > Assuming your data is 'vals': > > vals_masked = numpy.ma.masked_array(vals, vals == 0.0) > > Note that depending on your situation, doing an equality with with a > floating point value probably isn't very reliable, so be sure to test and > modify to suit your needs. 'vals_masked' can then be passed to pcolor > instead of vals. Yes, I think this is exactly what I need. Thanks! Jeremy 
From: Jeremy Conlin <jlconlin@gm...>  20100709 21:50:16

On Thu, Jul 8, 2010 at 8:41 AM, Jeremy Conlin <jlconlin@...> wrote: > On Sun, Jul 4, 2010 at 8:38 PM, Benjamin Root <ben.root@...> wrote: >> Jeremy, >> >> The pcolor function can take a vmin and a vmax parameter if you wish to >> control the colorscaling. In addition, you can use a special array >> structure called a "masked array" to have pcolor ignore "special" values. >> Assuming your data is 'vals': >> >> vals_masked = numpy.ma.masked_array(vals, vals == 0.0) >> >> Note that depending on your situation, doing an equality with with a >> floating point value probably isn't very reliable, so be sure to test and >> modify to suit your needs. 'vals_masked' can then be passed to pcolor >> instead of vals. > > Yes, I think this is exactly what I need. Thanks! > To follow up with my response, I tried the above and it works nicely with pyplot.pcolor. I would like to get a 3D version of this, like I get using Axes3D.plot_surface. Is this just not implemented yet? I am using 0.99.1.1. Has this been implemented in matplotlib 1.0? Thanks, Jeremy 
From: Benjamin Root <ben.root@ou...>  20100710 01:05:46
Attachments:
Message as HTML

Jeremy, I believe that 0.99.1 is fairly old. I don't know when Axes3D came along, but I am sure you can find it in 0.99.3. It is most definitely in 1.0, but you might not need to go that far if your distro does not provide it. Ben Root On Fri, Jul 9, 2010 at 4:50 PM, Jeremy Conlin <jlconlin@...> wrote: > On Thu, Jul 8, 2010 at 8:41 AM, Jeremy Conlin <jlconlin@...> wrote: > > On Sun, Jul 4, 2010 at 8:38 PM, Benjamin Root <ben.root@...> wrote: > >> Jeremy, > >> > >> The pcolor function can take a vmin and a vmax parameter if you wish to > >> control the colorscaling. In addition, you can use a special array > >> structure called a "masked array" to have pcolor ignore "special" > values. > >> Assuming your data is 'vals': > >> > >> vals_masked = numpy.ma.masked_array(vals, vals == 0.0) > >> > >> Note that depending on your situation, doing an equality with with a > >> floating point value probably isn't very reliable, so be sure to test > and > >> modify to suit your needs. 'vals_masked' can then be passed to pcolor > >> instead of vals. > > > > Yes, I think this is exactly what I need. Thanks! > > > > To follow up with my response, I tried the above and it works nicely > with pyplot.pcolor. I would like to get a 3D version of this, like I > get using Axes3D.plot_surface. Is this just not implemented yet? I > am using 0.99.1.1. Has this been implemented in matplotlib 1.0? > > Thanks, > Jeremy > 
From: Jeremy Conlin <jlconlin@gm...>  20100712 02:08:29

On Friday, July 9, 2010, Benjamin Root <ben.root@...> wrote: > Jeremy, > > I believe that 0.99.1 is fairly old. I don't know when Axes3D came along, but I am sure you can find it in 0.99.3. It is most definitely in 1.0, but you might not need to go that far if your distro does not provide it. Wince my first post, I have upgraded to 1.0 which definitely has Axes3D. The trouble is that the plot_surface function does not deal with masked arrays like color does. That is what I need and I haven't found a way around it. Jeremy 
From: Benjamin Root <ben.root@ou...>  20100712 19:22:04
Attachments:
Message as HTML

Ah, I misread your original post and thought you were talking about pcolor. I will take a look at plot_surface and see if there is a possible reason for your issue. I have an idea of what is happening, but I have to see the code when I get back to my office tomorrow. Ben Root On Sun, Jul 11, 2010 at 8:43 PM, Jeremy Conlin <jlconlin@...> wrote: > On Friday, July 9, 2010, Benjamin Root <ben.root@...> wrote: > > Jeremy, > > > > I believe that 0.99.1 is fairly old. I don't know when Axes3D came > along, but I am sure you can find it in 0.99.3. It is most definitely in > 1.0, but you might not need to go that far if your distro does not provide > it. > > Wince my first post, I have upgraded to 1.0 which definitely has > Axes3D. The trouble is that the plot_surface function does not deal > with masked arrays like color does. That is what I need and I haven't > found a way around it. > > Jeremy > 
Sign up for the SourceForge newsletter:
No, thanks