Re: scatter plot w/ colors

From: Alessandra Giannini <alesall_at_nyahnyahspammersnyahnyah>
Date: Fri, 16 Jan 2009 13:50:40 -0500

Adam,

thanks for your reply, and example. I can follow what you are doing,
but I still get this complaint:

"Not enough colors in colormap for number of contour levels"

The line is repeated many times - too many for me to try and count
them... ;-)

I checked the dimensions of the vectors, and even when I reduce the z,
sorted_z vectors to be smaller in dimension than the original color
map it gives me the same error.
The problem is in the line where the "GetFillColor" function is
applied - if I comment that out it runs, but obviously does not
produce the desired output.

Do you have any insights?

Thanks very much!
best, alessandra

On Jan 15, 2009, at 6:09 PM, Adam Phillips wrote:

> Hi Alessandra,
>
> If you wanted to automatically come up with your contour (for lack
> of a better word) levels, you can use nice_mnmxintvl first:
> http://www.ncl.ucar.edu/Document/Functions/Built-in/nice_mnmxintvl.shtml
>
> arr = nice_mnmxintvl(min(z),max(z),21,False)
> sorted_z = fspan(arr(0),arr(1),((arr(1)-arr(0))/arr(2))+1)
>
> Now let's say you wanted to use the BlWhRe colormap:
> http://www.ncl.ucar.edu/Document/Graphics/ColorTables/BlWhRe.shtml
>
> wks_define_colormap(wks,"BlWhRe")
> cmap = gsn_retrieve_colormap(wks)
> dimz = dimsizes(cmap)
> ncolors = dimz(0) ; number of colors
> c_ind = round(fspan(2,ncolors-1,dimsizes(sorted_z)+1),3) ; round to
> int
> do j=0,dimsizes(z)-1
> pres_at_gsMarkerColor=GetFillColor(sorted_z,cmap(c_ind,:),z(j))
> gsn_polymarker(wks,plota,x,y,pres)
> end do
>
> (untested) I think that will do it.. If that doesn't do what you
> want, let us know..
> Adam
>
> Alessandra Giannini wrote:
>> Hi everyone,
>> I am trying to figure out how to plot a scatterplot of THREE
>> variables in the following way:
>> the first variable runs along the x-axis, the second along the y-
>> axis and the third adds variation in color to the points.
>> To give you a prototypical example, here is a plot of average
>> temperature/precipitation colored by elevation in stations around
>> the central Mediterranean, computed in the IRI Data Library:
>> <http://iridl.ldeo.columbia.edu/expert/SOURCES/.NOAA/.NCDC/.GCPS/.MONTHLY/.STATION/lon/%280%29%2820%29masknotrange/SELECT/lat/%2835%29%2845%29masknotrange/SELECT/mean/temp%5BT%5Daverage/1/index/.prcp%5BT%5Daverage/3/index/.elev/fig://XOVY/1/def/scattercolor/:fig/
>> >
>> In NCL I tried this way a while back - start with the scatterplot
>> of 2 variables:
>> plot = gsn_csm_xy(wks,x,y,res)
>> and then add color:
>> pres = True
>> pres_at_gsMarkerIndex = (/ 16 /)
>> pres_at_gsMarkerSizeF = (/ 0.01 /)
>> do j=0,dimsizes(z)-1
>> pres_at_gsMarkerColor=GetFillColor(sorted_z,cmap,z(j))
>> gsn_polymarker(wks,plota,x,y,pres) end do
>> where cmap is defined from an array or RGB values, stored in an
>> external file:
>> cmap = RGBtoCmap("csimple.txt")
>> that typically looks like this:
>> 255 255 255
>> 0 0 0
>> 0 0 128
>> 0 0 205
>> 30 144 255
>> 0 191 255
>> 127 255 212
>> 255 255 255
>> 255 255 0
>> 255 215 0
>> ...
>> My problem is in defining a color scale automatically, in the sense
>> that I would like to be able to just pick out a color map
>> regardless of the number of points in the scatter - one of the
>> classic color scales defined in ncl would do, like BlueRed.
>> Can I do that? And if so, how?
>> Your help is much appreciated.
>> thanks, alessandra
>> --
>> Alessandra Giannini
>> IRI for Climate and Society - The Earth Institute at Columbia
>> University
>> P.O. Box 1000, Palisades NY 10964-8000
>> phone/fax: +1 845 680-4473/4864 - email: alesall_at_iri.columbia.edu <mailto:alesall_at_iri.columbia.edu
>> >
>> ------------------------------------------------------------------------
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
> --
> --------------------------------------------------------------
> Adam Phillips asphilli_at_ucar.edu
> National Center for Atmospheric Research tel: (303) 497-1726
> ESSL/CGD/CAS fax: (303) 497-1333
> P.O. Box 3000
> Boulder, CO 80307-3000 http://www.cgd.ucar.edu/cas/asphilli

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Jan 16 2009 - 11:50:40 MST

This archive was generated by hypermail 2.2.0 : Fri Jan 16 2009 - 14:05:56 MST