Re: Drawing order for polymarkers

From: Dave Allured <dave.allured_at_nyahnyahspammersnyahnyah>
Date: Wed, 16 Sep 2009 15:01:35 -0600

Rick and Adam,

I tested both of your suggestions -- with and without
tfPolyDrawList. In both cases, all documented settings for
tfPolyDrawOrder seem to be ignored. Please see two attached test
scripts. I am using NCL 5.1.1 on Mac OS 10.5 PPC.

I was not specific enough in my original message. I need to control
polymarker/polygon drawing order with respect to other plot elements
in the base plot. I would like to use tfPolyDrawOrder, not the
other DrawOrder resources, because the latter sometimes come with
cascading side effects.

Am I doing something wrong? If not, would it be possible to get
tfPolyDrawOrder working as documented in conjunction with gsn base
plot functions? These are the particular base functions that I need
currently:

   gsn_csm_contour_map_ce
   gsn_csm_vector_scalar_map_ce
   gsn_csm_contour (as overlay)

Thanks for your help.

--Dave

Rick Brownrigg wrote on Sept 10:
> Thanks for that pointer, Adam -- I was unaware of these resources.
>
> It looks like if finer grain control over which lines/markers/polygons
> get drawn first/last can be controlled with a related resource:
> "tfPolyDrawList". The following snippet draws two filled and
> overlapping boxes over a map of US:
>
> boxes = new((/2/), graphic)
> bRes=True
> bRes_at_gsFillColor = "green"
> x = (/-110, -90, -90, -110/)
> y = (/40, 40, 30, 30/)
> boxes(1) = gsn_add_polygon(wks, plot, x, y, bRes)
>
> bRes_at_gsFillColor = "red"
> x = (/-100, -80, -80, -100/)
> y = (/35, 35, 25, 25/)
> boxes(0) = gsn_add_polygon(wks, plot, x, y, bRes)
>
> dummy = new(1,graphic)
> NhlAddPrimitive(plot, boxes, dummy)
>
> In this case, the green box is drawn last. Reordering the assignments
> in "boxes" causes the red polygon to be drawn last.
>
> FWIW...
> Rick
>
> On Sep 10, 2009, at 9:22 AM, Adam Phillips wrote:
>
>> Hi Dave,
>> I just became aware of this resource recently:
>> res_at_tfPolyDrawOrder = "PreDraw" ; Draw any attached
>> primitives
>> ;
>> before rest of plot.
>> http://www.ncl.ucar.edu/Document/Graphics/Resources/tf.shtml#tfPolyDrawOrder
>>
>> So give tfPolyDrawOrder a shot and let us know if that solves your
>> problem..
>> Best regards,
>> Adam
>>
>> Dave Allured wrote:
>>> NCL team,
>>>
>>> I need to control the drawing order of polylines and polymarkers.
>>> In a typical case, the base plot is made with
>>> gsn_csm_vector_scalar_map_ce, plus an overlay made with
>>> gsn_csm_contour.
>>>
>>> I find a number of DrawOrder resources, but none seem to apply to
>>> objects made with gsn_add_poly* functions. In general, what is the
>>> right way to control drawing order for these? I'm using NCL 5.1.1.
>>> Thanks for your help.

; polytest1.ncl -- Test drawing order resource for polymarkers.
; By Dave Allured, 2009-sep-15.

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"

begin
  in = addfile("80.nc","r") ; data file from NCL website
  TS = in->TS(0,:,:) ; read single lat/lon grid

  wks = gsn_open_wks ("x11", "polytest1.plot" ) ; open workstation
 
  res = True ; base plot resources
  res_at_gsnDraw = False
  res_at_gsnFrame = False
  res_at_mpFillOn = False ; turn off land area fill

  pres = True ; polymarker resources
  pres_at_gsMarkerColor = "palegreen"
  pres_at_gsMarkerIndex = 16 ; 16 = solid circle
  pres_at_gsMarkerSizeF = 60

  res_at_tfPolyDrawOrder = "PostDraw" ; test DrawOrder resource
  pres_at_tfPolyDrawOrder = "PostDraw" ; test in both places

  plot = gsn_csm_contour_map_ce (wks, TS, res) ; make base plot
  dummy = gsn_add_polymarker (wks, plot, -5, 45, pres)
                                         ; overlay polymarker
  draw(plot)
  frame(wks)
end

; polytest2.ncl -- Test drawing order resource for polymarkers.
; By Dave Allured, 2009-sep-15.

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"

begin
  in = addfile("80.nc","r") ; data file from NCL website
  TS = in->TS(0,:,:) ; read single lat/lon grid

  wks = gsn_open_wks ("x11", "polytest2.plot" ) ; open workstation
 
  res = True ; base plot resources
  res_at_gsnDraw = False
  res_at_gsnFrame = False
  res_at_mpFillOn = False ; turn off land area fill

  pres = True ; polymarker resources
  pres_at_gsMarkerColor = "palegreen"
  pres_at_gsMarkerIndex = 16 ; 16 = solid circle
  pres_at_gsMarkerSizeF = 60

  bRes=True
  res_at_tfPolyDrawOrder = "PostDraw" ; test DrawOrder resource
  bRes_at_tfPolyDrawOrder = "PostDraw" ; test in both places

  plot = gsn_csm_contour_map_ce (wks, TS, res) ; make base plot

  boxes = new((/2/), graphic)
  bRes=True
  bRes_at_gsFillColor = "green"
  x = (/-110, -90, -90, -110/)
  y = (/40, 40, 30, 30/)
  boxes(1) = gsn_add_polygon(wks, plot, x, y, bRes)

  bRes_at_gsFillColor = "red"
  x = (/-100, -80, -80, -100/)
  y = (/35, 35, 25, 25/)
  boxes(0) = gsn_add_polygon(wks, plot, x, y, bRes)

  dummy = new(1,graphic)
  NhlAddPrimitive(plot, boxes, dummy) ; overlay two polylines

  draw(plot)
  frame(wks)
end

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Sep 16 2009 - 15:01:35 MDT

This archive was generated by hypermail 2.2.0 : Fri Sep 18 2009 - 15:36:15 MDT