[ncl-talk] Changing a color in a color table to transparent

Ty Buckingham ty.buckingham at manchester.ac.uk
Wed Apr 11 10:07:38 MDT 2018


I see, thanks a lot for the help! It works perfectly now.

Cheers
Ty
________________________________
From: Mary Haley [haley at ucar.edu]
Sent: 11 April 2018 16:38
To: Rashed Mahmood
Cc: Ty Buckingham; ncl-talk at ucar.edu
Subject: Re: [ncl-talk] Changing a color in a color table to transparent

Just a minor suggestion: if you want transparency, the value to change is the "alpha" value, which is represented by index 3 (indexes 0 through 2 are the RGB values):

cmap(10:11,3)        = 0.0    ; completely transparent
cmap(10:11,3)        = 0.5    ; half transparent
cmap(10:11,3)        = 1.0    ; no transparency (the default)

See example newcolor_10.ncl at:

http://www.ncl.ucar.edu/Applications/rgbacolor.shtml#ex10

I think other examples on that page may be useful.


On Tue, Apr 10, 2018 at 5:41 PM, Rashed Mahmood <rashidcomsis at gmail.com<mailto:rashidcomsis at gmail.com>> wrote:
I think there is typo, replace:
From:
cmap(10:11,)        = 0.0

to cmap(10:11,:)        = 0.0

If at later stage you are using "gsn_define_colormap" then it should be:
cmap(10:11,0:2)        = 0.0

Cheers,
Rashed



On Tue, Apr 10, 2018 at 4:55 PM, Ty Buckingham <ty.buckingham at manchester.ac.uk<mailto:ty.buckingham at manchester.ac.uk>> wrote:
Hi there,

Is it possible to change a single color in an already constructed color map to transparent?

As an example: I wish to use the "hotcold_18lev" color table, but wish to change the white to transparent. I do not have editing permission to the NCARG root hence cannot change the RGBA value directly. Is it possible to change it within the NCL script?

Initially, I tried this:


cmap                = read_colormap_file("hotcold_18lev")

cmap(10:11,)        = 0.0                ; makes whites transparent

res at cnFillColors    = cmap


Yet received the error:


fatal:Error in subscript, normal subscripting is being used, make sure named subscripting has not been used


which is related to the "cmap(10:11,)" line.


Thanks in advance!

Ty

_______________________________________________
ncl-talk mailing list
ncl-talk at ucar.edu<mailto:ncl-talk at ucar.edu>
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk



_______________________________________________
ncl-talk mailing list
ncl-talk at ucar.edu<mailto: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/20180411/7da26b3a/attachment.html>


More information about the ncl-talk mailing list