load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" begin a = addfile("$NCARG_ROOT/lib/ncarg/data/cdf/uv300.nc","r") u = a->U(1,:,:) ; read July zonal winds levels = ispan(-10,35,5) colors = (/"White","WhiteSmoke","Gray85","DodgerBlue","Navyblue",\ "DodgerBlue2","Green","Purple","SteelBlue","Goldenrod","SteelBlue2"/) wks = gsn_open_wks("png","opacity_example") res = True res@cnFillOn = True res@cnLevelSelectionMode = "ExplicitLevels" res@cnLevels = levels res@mpFillOn = False ; turn off the gray-filled land res@cnFillColors = colors res@tiMainString = "Colors are fully opaque" plot1 = gsn_csm_contour_map(wks,u,res) ;---Make four of the colors partially transparent rgba = namedcolor2rgba(colors) ; convert named colors to n x 4 RGBA array rgba(4,3) = 0.25 rgba(5,3) = 0.5 rgba(6,3) = 0.75 rgba(7,3) = 0.90 res@cnFillColors := rgba res@tiMainString = "Middle four colors have varying levels of opaqueness" plot2 = gsn_csm_contour_map(wks,u,res) gsn_panel(wks,(/plot1,plot2/),(/2,1/),True) end