# Re: scatter plot w/ colors

Date: Thu, 15 Jan 2009 16:09:14 -0700

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..

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:
>
> In NCL I tried this way a while back - start with the scatterplot of 2
> variables:
>
> plot = gsn_csm_xy(wks,x,y,res)
>
>
> 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

```--
--------------------------------------------------------------
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 Thu Jan 15 2009 - 16:09:14 MST

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