Re: color fills with transparency

From: <brownrig_at_nyahnyahspammersnyahnyah>
Date: Wed Jun 20 2012 - 10:32:04 MDT

Hi Mark,

I'm not sure what you are trying to do. If you want the lines in your
graph to be translucent, try the "gsLineOpacityF"
resource, which takes a float from 0. (transparent) to 1. (completely
opaque).

You might also take a look at:

     http://ncl.ucar.edu/Applications/rgbacolor.shtml

where the new color resources are described.

Hope that helps...
Rick

On Wed, 20 Jun 2012 17:55:57 +1000
  <Mark.Collier@csiro.au> wrote:
> Hi,
> I have some experience with using transparency with an older
>unofficial version of NCL, however, I'm having trouble getting this
>feature to work in the latest version which has this capability.
>
> [mac599@dcc Steve]$ ncl -V
> 6.1.0-beta
>
> [mac599@dcc Steve]$ uname -a
> Linux dcc 2.6.18-274.7.1.el5 #1 SMP Thu Oct 20 16:21:01 EDT 2011
>x86_64 x86_64 x86_64 GNU/Linux
>
> I have put the following files into the incoming ftp area for
>examination:
>
> tas_Amon_CSIRO-Mk3-6-0_historical_r1i1p1_1850-2005_c1850-1899_ANN_YA.nc
> tas_Amon_CSIRO-Mk3-6-0_historical_r2i1p1_1850-2005_c1850-1899_ANN_YA.nc
> tas_Amon_CSIRO-Mk3-6-0_rcp45_r1i1p1_2006-2100_chistorical_r1i1p1_1850-1899_ANN_YA.nc
> tas_Amon_CSIRO-Mk3-6-0_rcp45_r2i1p1_2006-2100_chistorical_r2i1p1_1850-1899_ANN_YA.nc
> tas_Amon_hadcrut3_glts_r1i1p1_1850-2010_c1850-1899_ANN_YA.nc
> try.ncl
>
> The script is copied below.
>
> I assume it is got something to do with gsFillOpacityF - sets
>opacity for color-filled polygons
>
> But I cannot find an example of its implementation or my attempts
>failed.
>
> Thanks for any help,
> Mark.
>
>
> load "/home/599/mac599/marsland/all_scripts.ncl"
>
> begin
>
> rad = 4.0*atan(1.0)/180.0
>
> nens=2
>
> obs="tas_Amon_hadcrut3_glts_r1i1p1_1850-2010_c1850-1899_ANN_YA.nc"
>
> histrcp=new(2,string)
> do ens=1,nens
>
> historical="tas_Amon_CSIRO-Mk3-6-0_historical_r"+ens+"i1p1_1850-2005_c1850-1899_ANN_YA.nc"
>
> rcp45="tas_Amon_CSIRO-Mk3-6-0_rcp45_r"+ens+"i1p1_2006-2100_chistorical_r"+ens+"i1p1_1850-1899_ANN_YA.nc"
>
> histrcp(0)=historical
> histrcp(1)=rcp45
>
> fh_obs=addfile(obs,"r")
> fh_historical=addfile(historical,"r")
> fh_rcp45=addfile(rcp45,"r")
> fh_histrcp = addfiles(histrcp,"r")
>
> if(ens.eq.1)then
> lat = fh_historical->lat
> clat = doubletofloat(cos(lat*rad))
> clat!0 = "lat"
> clat&lat = lat
>
> dims_historical=filevardimsizes(fh_historical,"tas")
> dims_rcp45=filevardimsizes(fh_rcp45,"tas")
> ntim_historical=dims_historical(0)
> ntim_rcp45=dims_rcp45(0)
> histrcpobs_data = new((/2,ntim_historical+ntim_rcp45/),float)
> histrcp_data = new((/nens,ntim_historical+ntim_rcp45/),float)
> histrcp_minmax = new((/2,ntim_historical+ntim_rcp45/),float)
> histrcpobs_data@_FillValue=1e20
> histrcpobs_data@missing_value=histrcpobs_data@_FillValue
> histrcpobs_data=0.0
> histrcpobs_time_year = cd_calendar(fh_histrcp[:]->time,4)
> end if
>
> histrcp_data(nens-1,:)=wgt_areaave(fh_histrcp[:]->tas, clat, 1.0, 0)
>
> histrcpobs_data(0,:)=histrcpobs_data(0,:)+wgt_areaave(fh_histrcp[:]->tas,
>clat, 1.0, 0)
> end do
> histrcpobs_data(0,:)=histrcpobs_data(0,:)/nens
>
>
> histrcp_minmax(0,:)=dim_min_n(histrcp_data,0)
> histrcp_minmax(1,:)=dim_max_n(histrcp_data,0)
>
> histrcpobs_data(1,:)=1e20
> histrcpobs_data(1,0:160)=fh_obs->tas
>
> outp="try"
>
> wks = gsn_open_wks ("ps",outp)
> ; wks = gsn_open_wks ("X11",outp)
>
> alpha = 0.30 ; 1.0 is fully opaque (?)
> red_trn = (/0.80,0.00,0.00,alpha/)
>
> plots = new(2,graphic)
>
> res = True ; plot mods
>desired
> res@gsnDraw = False ; don't draw yet
> res@gsnFrame = False ; don't advance frame yet
> res@xyLineColors = (/"red","blue","green","black"/) ;
>change line color
> res@xyLineThicknesses = (/2.0,2.0,2.0,2.0/) ; make 2nd
>lines thicker
> res@xyDashPattern = 0 ; Make curves all solid
> res@pmLegendDisplayMode = "Always" ; turn on legend
> res@pmLegendSide = "Top" ; Change location
>of
> res@pmLegendParallelPosF = .40 ; move units
>right
> res@pmLegendWidthF = 0.12 ; Change width
>and
> res@pmLegendHeightF = 0.15 ; height of
>legend.
> res@lgLabelFontHeightF = .02 ; change font
>height
> res@lgPerimOn = False ; no box around
>
> res@tmXBLabelsOn = True
> ; res@tmXBOn = False
>
> res@vpWidthF = 0.95
>
> res_lines = True ; polyline mods
>desired
> res_lines@gsLineThicknessF = 2. ; line thicker
> res_lines@gsLineColor = "gray"
> res_lines@gsLineDashPattern = 1
>
> res@gsnLeftString = "(a) Globally averaged surface air temperature
>anomalies"
> res@tiYAxisString = "~S~o~N~C"
> res@tiXAxisString = "Year"
> res@xyExplicitLegendLabels = (/" historical/rcp45"," observed"/)
> res@trXMinF = 1850.
> res@trXMaxF = 2100. ; set x-axis minimum
> res@trYMinF = -1.
> res@trYMaxF = 3.
> res@pmLegendOrthogonalPosF = -0.5 ; more neg = down
>
> plots(0) = gsn_csm_xy
>(wks,histrcpobs_time_year,histrcpobs_data,res) ; create plot
>
> res@gsnLeftString = "(b) Globally averaged surface air temperature
>anomalies"
> res@tiYAxisString = "~S~o~N~C"
> res@tiXAxisString = "Year"
> res@xyExplicitLegendLabels = (/" historical/rcp45"," observed"/)
> res@trXMinF = 1850.
> res@trXMaxF = 2100. ; set x-axis minimum
> res@trYMinF = -1.
> res@trYMaxF = 3.
> res@pmLegendOrthogonalPosF = -0.5 ; more neg = down
> plots(1) = gsn_csm_xy
>(wks,histrcpobs_time_year,histrcpobs_data,res) ; create plot
>
> delete(res@xyLineColors)
> res@gsnXYFillColors = red_trn
> res@xyLineColor = -1 ; We don't want
>the line, so make it transparent.
>
> ; res@gsnDraw = True
>
> plots1b = gsn_csm_xy (wks,histrcpobs_time_year,histrcp_minmax,res)
> overlay(plots(1),plots1b)
>
> resP = True ; modify the panel
>plot
>
> resP@gsnPanelLeft = 0.05
>
> resP@gsnPanelBottom = 0.2 ; shrink panel plot
>by setting bottom edge of plot
> resP@gsnPanelTop = 0.9 ; shrink panel plot
>by setting top edge of plot
>
> gsn_panel(wks,plots,(/2,1/),resP) ; now draw as one
>plot
>
> print("Finished "+outp+".")
>
> end
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Jun 20 10:32:08 2012

This archive was generated by hypermail 2.1.8 : Mon Jun 25 2012 - 09:57:23 MDT