Re: Adding a Box

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Sun, 10 Dec 2006 05:20:35 -0700 (MST)

On Fri, 8 Dec 2006, Adam Phillips wrote:

> Hi Baode,
>
> I do not believe you are allowed to delete the graphic array p1 before the
> plots are drawn using gsn_panel. So, I would try commenting out the
> delete(p1) line. If that still doesn't work I would try calling
> gsn_add_polygon after the gsn_panel call, as in polygon example 10 found
> here:

Adam is correct: you cannot delete *any* variable that you use on the
lefthand side of a gsn_add_polyxxx call. These variables also have to
be unique, so that's why it's good to use an array, or else individual
variables with different names.

--Mary

> https://www.ncl.ucar.edu/Applications/Scripts/polyg_10.ncl
>
> Thus, the bottom of your script would change from this:
> p1=new(6,graphic)
> do j = 0, 5
> p1(j) = gsn_add_polygon (wks,p(j),xpts,ypts,resb)
> end do
> ; delete(p1)
> delete(resb)
> resP = True
> resP_at_gsnPanelLabelBar = True ; add common colorbar
> gsn_panel(wks,p,(/3,2/),False)
> end
>
> to this:
> resP = True
> resP_at_gsnFrame = False
> resP_at_gsnPanelLabelBar = True ; add common colorbar
> gsn_panel(wks,p,(/3,2/),resP)
> p1=new(6,graphic)
> do j = 0, 5
> p1(j) = gsn_add_polygon (wks,p(j),xpts,ypts,resb)
> end do
> frame(wks)
> end
>
> Good luck...
> Adam
>
> Baode Chen wrote:
>> Hi, ALL
>>
>>
>> I tried to add a box in each plot for a group of plots. But I got the error
>> message as followings
>>
>> warning:TransformPostDraw: tfPolyDrawList element 0 is invalid
>> warning:TransformPostDraw: tfPolyDrawList element 0 is invalid
>> warning:TransformPostDraw: tfPolyDrawList element 0 is invalid
>> warning:TransformPostDraw: tfPolyDrawList element 0 is invalid
>> warning:TransformPostDraw: tfPolyDrawList element 0 is invalid
>> warning:prXArray isn't a resource in this object
>> warning:prYArray isn't a resource in this object
>> warning:prPolyType isn't a resource in this object
>> warning:prGraphicStyle isn't a resource in this object
>> Segmentation fault
>>
>>
>> The following is my script
>>
>> ;************************************************
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
>> ;************************************************
>> begin
>> prp = new((/6,180,360/),"float")
>> in = "ITCZ.comp3.dat"
>> do i = 0, 5
>> prp(i,:,:) = fbinrecread(in,i,(/180,360/),"float")
>> end do
>> lon = fspan(0.5,359.5,360)
>> lat = fspan(89.5,-89.5,180)
>> at = new(6,"string")
>> at(0) = "South ITCZ"
>> at(1) = "Equator ITCZ"
>> at(2) = "Double ITCZ"
>> at(3) = "North ITCZ"
>> at(4) = "Full ITCZ"
>> at(5) = "Weak ITCZ"
>> p = new(6,graphic)
>> prp!1="lat"
>> prp&lat = lat
>> prp!2="lon"
>> prp&lon = lon
>> prp&lat_at_units = "degree_north"
>> prp&lon_at_units = "degree_east"
>> prp@_FillValue = -999.0
>> wks = gsn_open_wks("x11","SP3")
>> gsn_define_colormap(wks,"wh-bl-gr-ye-re")
>> d = NhlNewColor(wks,0.8,0.8,0.8)
>> res = True
>> res_at_gsnDraw = False ; don't draw
>> res_at_gsnFrame = False ; don't advance frame
>> res_at_cnInfoLabelOn = False ; turn off cn info label
>> res_at_cnLinesOn = False
>> res_at_cnFillOn = True ; turn on color
>> res_at_cnLevelSelectionMode = "ManualLevels" ; set manual contour levels
>> res_at_cnMinLevelValF = 1. ; set min contour level
>> res_at_cnMaxLevelValF = 15. ; set max contour level
>> res_at_cnLevelSpacingF = 0.5 ; set contour spacing
>> res_at_gsnSpreadColors = True ; spread out color table
>> res_at_gsnAddCyclic = True ; plotted dataa are not cyclic
>> res_at_mpFillOn = False ; turn off map fill
>> res_at_lbLabelAutoStride = True
>> res_at_gsnSpreadColorEnd = -3 ; don't use added gray
>> res_at_mpCenterLonF = 180
>> res_at_mpCenterLonF = 180
>> res_at_mpMaxLatF = 35.0 ; area to zoom in on
>> res_at_mpMinLatF = -35.
>> res_at_mpMinLonF = 100.
>> res_at_mpMaxLonF = 250.
>> res_at_gsnMaximize = True
>>
>> res_at_lbLabelBarOn = False ; turn off individual cb's
>> res_at_pmTickMarkDisplayMode = "Always"; use NCL default lat/lon labels
>> res_at_lbOrientation = "Vertical" ; vertical label bar
>> res_at_cnFillDrawOrder = "PreDraw" ; draw contours before continents
>> res_at_gsnMaximize = True
>> res_at_gsnPaperOrientation = "landscape"
>>
>> do i = 0, 5
>> res_at_tiMainString = at(i)
>> p(i) = gsn_csm_contour_map_ce(wks,prp(i,:,:),res)
>> end do
>>
>> ; add the box
>> ypts = (/ 10.0, 10.0, -10. , -10., 10.0/)
>> xpts = (/ 130., 210.0, 210.0, 130.0,130.0/)
>> do i = 0, 4
>> print(xpts(i)+" "+ypts(i))
>> end do
>>
>> resb = True
>> resb_at_gsLineColor = "red" ; color of lines
>> resb_at_gsLineThicknessF = 2.0
>> p1=new(6,graphic)
>> do j = 0, 5
>> p1(j) = gsn_add_polygon (wks,p(j),xpts,ypts,resb)
>> end do
>> delete(p1)
>> delete(resb)
>> resP = True
>> resP_at_gsnPanelLabelBar = True ; add common colorbar
>> gsn_panel(wks,p,(/3,2/),False)
>> end
>> .
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk_at_ucar.edu
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
> --
> --------------------------------------------------------------
> Adam Phillips asphilli_at_ucar.edu
> National Center for Atmospheric Research tel: (303) 497-1726
> ESSL/CGD/CAS fax: (303) 497-1333
> P.O. Box 3000 Boulder, CO 80307-3000
> http://www.cgd.ucar.edu/cas/asphilli
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Sun Dec 10 2006 - 05:20:35 MST

This archive was generated by hypermail 2.2.0 : Sun Dec 10 2006 - 19:25:38 MST