Re: Help: can not change the color of polygon in function call?

From: Rick Brownrigg <brownrig_at_nyahnyahspammersnyahnyah>
Date: Mon Apr 12 2010 - 16:23:27 MDT

Hi Li,

I think if you want the polygons to be red, then you want to set
gsFillColor = "red", rather than "gsFillColor = True".

Hope that helps...
Rick

On Apr 12, 2010, at 4:16 PM, lxf wrote:

> Hi,
> I met a little trouble in changing the color of polygon in
> function call, which means that the black color of polygon can not
> be changed even if I changed the setting:
> gsres@gsLineColor = "red"
> in the function "sub_draw_add".
>
> To simplify my problem, I write the following script (which is
> revised from http://www.ncl.ucar.edu/Applications/Scripts/
> xy_12.ncl ) in the end of the letter and the output eps figure is
> also attaced behind.
>
> Any suggestion and help is appriciated.
>
>
> ;*************************************************
> ; xy_12.ncl
> ;
> ; Concepts illustrated:
> ; - Emphasizing part of a curve in an XY plot
> ; - Drawing longitude labels on the X axis
> ;
> ;************************************************
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> ;*******************************************
> undef("sub_draw")
> function sub_draw(wks,xaxis,index)
> local wks,res,index,plot,xaxis
> begin
>
> res = True ; plot mods
> desired
> res@tiYAxisString = "" ; add units to title
> res@tfPolyDrawOrder = "Predraw" ; put line
> on top
> res@tiMainString = "Highlight Part of a Line" ; title
>
> res@xyDashPatterns = (/0.,0./) ; keep all
> solid
>
> res@gsnFrame = False ; don't draw
> yet
> res@gsnDraw = False ; don't
> advance yet
>
> plot = gsn_csm_xy(wks,xaxis,index,res) ; create plot
>
> return(plot)
> end
> ;*******************************************
> undef("sub_draw_add")
> function sub_draw_add(wks,plot,xp,yp)
> local plot,xp,yp,dname,dum
> begin
> ;
> ; hight the line use p
> ;
> gsres = True ; poly res
> ;gsres@gsnFrame = False ; don't draw
> yet
> ;gsres@gsnDraw = False ; don't
> advance yet
> gsres@gsFillColor = True
> gsres@gsLineColor = "red" ; color chosen
>
>
> dum = gsn_add_polygon(wks,plot,xp,yp,gsres) ; draw polygon
> dname = unique_string("dum")
> plot@$dname$ = dum
>
> return(plot)
> end
> ;************************************************
>
>
>
> begin
> ; read in netCDF file
> ;------------------------------------------------
> a = addfile("uv300.nc","r")
> u = a->U(0,:,{60})
> lat= a->lat
>
> ;
> ; First polygon
> ;...
> data = u({-60:-30})
> ndata= dimsizes(data)
> print(ndata)
>
> yp = new(ndata+1,typeof(data))
> yp(0:ndata-1) = u({-60:-30})
> yp(ndata) = yp(0)
>
> xp = new(ndata+1,typeof(lat))
> xp(0:ndata-1) = lat({-60:-30})
> xp(ndata) = xp(0)
>
> ;
> ; Second polygon
> ;...
> delete(data)
> delete(ndata)
> data = u({0:60})
> ndata = dimsizes(data)
> print(ndata)
> printVarSummary(data)
>
> yp2 = new(ndata+1,typeof(data))
> printVarSummary(yp2)
> printVarSummary(u({0:60}))
> yp2(0:ndata-1) = u({0:60})
> yp2(ndata) = yp2(0)
>
> xp2 = new(ndata+1,typeof(lat))
> xp2(0:ndata-1) = lat({0:60})
> xp2(ndata) = xp2(0)
>
> ;
> ; draw line
> ;...
> outname = "1"
> wks = gsn_open_wks("eps",outname)
>
> plot = sub_draw(wks,lat,u)
>
> ;
> ; draw polygon
> ;...
>
> plot=sub_draw_add(wks,plot,xp,yp)
>
> plot=sub_draw_add(wks,plot,xp2,yp2)
>
>
> draw(plot)
> frame(wks)
> end
>
>
> Li<1.eps>_______________________________________________
> 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 Mon Apr 12 16:23:37 2010

This archive was generated by hypermail 2.1.8 : Wed Apr 14 2010 - 09:15:22 MDT