# [ncl-talk] Can i set the opacity of each color ??

Rabah Hachelaf hachelaf at sca.uqam.ca
Thu Aug 28 19:44:38 MDT 2014

```Hi all ,

I am using the script below to plot humidity between 40-70%(green) and
70-100% (orange).

I want to know if i can set the opacity for each color for example opacity
50% for the green color and 100% for the orange.

Thanks for help.

;************************************************
;************************************************
begin
lon = a->lon_0
lat = a->lat_0
icing     = short2flt(a->RH_P0_L100_GLL0({50000},:,:))

print(icing(1:4,1:4))
;********************************************************
;  Display parameters
;***************************************
zoom="test"
pixel=2048
;***************************************************

wks_type="png"

wks_type at wkWidth = pixel
wks_type at wkHeight = pixel
wks_type at wkBackgroundOpacityF = 0.0
wks = gsn_open_wks(wks_type,"icing_test")

colors = (/ (/255,255,255/),(/0,0,0/),(/255,255,255/), (/244,255,244/), \
(/217,255,217/), (/163,255,163/), (/106,255,106/), \
(/43,255,106/), (/0,224,0/), (/0,134,0/),(/255,145,0/),\
(/255,178,102/) /) * 1.0 ; we multiply by 1 to make colors
float

colors = colors/255.

gsn_define_colormap(wks,colors)

res                   = True
res at mpProjection      = "Mercator"       ; choose projection
res at mpGridAndLimbOn   = False             ; turn on lat/lon lines
res at mpPerimOn         = False             ; turn off box around plot
res at mpFillOn          = False
res at mpOutlineOn       = True
res at cnFillOn          = True              ; color plot desired
res at cnLineLabelsOn    = False             ; turn off contour lines
res at mpLimitMode  = "LatLon"
res at mpMinLatF            =   -85.0
res at mpMaxLatF            =  85.0
res at mpMinLonF            = -180
res at mpMaxLonF            = 180
res at vpXF            = 0                 ; make plot bigger
res at vpYF            = 1
res at vpWidthF        = 1
res at vpHeightF       = 1

res at cnLevelSelectionMode = "ExplicitLevels"    ; set explicit contour levels
res at cnLevels    = (/ 40,70,100/) ; set levels
res at cnFillColors = (/ -1,5,11/)

;res at cnFillOpacityF=0.5

contour0 = gsn_csm_contour_map(wks,icing,res)  ; create the plot
--
------------------------------
Cordialement,
Best regards,
Rabah Hachelaf

--
------------------------------
Cordialement,
Best regards,
Rabah Hachelaf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20140828/2b59122a/attachment.html
```