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

Mary Haley haley at ucar.edu
Wed Apr 11 09:38:33 MDT 2018


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>
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> 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
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>
> _______________________________________________
> 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/20180411/35730dec/attachment.html>


More information about the ncl-talk mailing list