[ncl-talk] printing the names of colors used in legendbar of contour plot

Tabish Ansari tabishumaransari at gmail.com
Thu Sep 8 21:07:35 MDT 2016


Hi Mary,

Thanks for providing this script. I've been able to plot my required wrf
data alongside observational station data with the same colorscale.
However, my WRF data is on a Lambert Conformal projection but this scripts
plots it on a cylindrical equidistant projection. I would like to plot it
nicely on its native projection i.e., lambert conformal.

I would also like to switch on the map boundaries (national and state, grid
lines, geophysical etc.) on both the plots. Could you please help me do
this?

Thanks a lot!

Tabish

Tabish U Ansari
PhD student, Lancaster Environment Center
Lancaster Univeristy
Bailrigg, Lancaster,
LA1 4YW, United Kingdom

On 28 August 2016 at 20:11, Mary Haley <haley at ucar.edu> wrote:

> ​Hi Tabish,
>
> Here's a some extra information on colors in NCL:
>
> -------------------------------------------------------------------------
> When you use a predefined colormap, like "rainbow" or "amwg", it is not
> defined by named colors, by rather by RGBA quadruplets.
>
> RGBA arrays are N x 4 floating point arrays of values that go from 0 to 1,
>  where the 'RGB' represents fractions of red, green, and blue, and the 'A'
> represents the 'alpha' value which designates the opacity of the color.
>
> For example:
>
> The color (/1.0,0.,0.,1./)  represents red, because you have full red
> (1.0), no green (0.0), no blue (0.0), and full opacity (1.0).
>
> The color (/0.0,1.0,0.0,1./) represents green, with full opacity.
>
> The color (/0.0,0.0,1.0,0.5/) represents blue, with half opacity.
>
> The color (/1.0,1.0,0.0,0.25/) represents yellow, with a quarter opacity.
>
> etc.
>
> In NCL, when you specify a color resource like:
>
>   res at gsMarkerColor = "red"
>
> you can use named colors, but you can also use direct RGBA values:
>
>   res at gsMarkerColor = (/1.,0.,0.,1./)   ; fully opaque red marker
>
> The nice thing about using RGBA values is it allows you to control the
> opacity, for example:
>
>   res at gsMarkerColor = (/1.,0.,0.,0.25/)   ; mostly transparent red marker
> ---------------------------------------------------------------------
>
> Anyway, you can mimic the colors that NCL uses in your WRF plot, by using
> span_color_rgba.  You need to give this function the same levels that you
> are using for the contour plot, and it will return the same colors being
> used by the contour plot. Note, you could accomplish the same thing by
> calling "getvalues" on the smoothed contour plot to retrieve the levels and
> the colors.
>
> See the attached script, which creates a filled contour plot of SLP, and
> then randomly grabs points from SLP to mimic an observational data set, but
> draws these values using filled square markers.
>
> You can get the dataset from:
>
> http://www.ncl.ucar.edu/Applications/Data/cdf/wrfout_
> d01_2003-07-15_00:00:00
>
> --Mary
>
>
>
> On Sat, Aug 27, 2016 at 9:38 PM, Tabish Ansari <tabishumaransari at gmail.com
> > wrote:
>
>> Hi
>>
>> I'm trying to compare wrf model output (contour plot) with some station
>> data (scattered observations). I am trying to color the markers of the
>> station data based on their values and create a similar legend bar as the
>> wrf-contour. However, this is not very straightforward as I'm using
>> predefined colormap for wrf-contour but have to explicitly specify the name
>> of the color for each range in case of station data.
>>
>> This will be very easy if I know the exact name of each shade used in the
>> legend bar of wrf-contour (out of the 650 named colors in NCL). Is there a
>> way to print the names of these colors used in the legendbar?
>>
>> Thanks
>>
>> Tabish
>>
>> Tabish U Ansari
>> PhD student, Lancaster Environment Center
>> Lancaster Univeristy
>> Bailrigg, Lancaster,
>> LA1 4YW, United Kingdom
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160909/a42d4a62/attachment.html 


More information about the ncl-talk mailing list