Re: text over a grid

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Fri Mar 22 2013 - 09:58:15 MDT

Hi Rosemarie,

If you are adding the text using gsn_add_text, then this should always cause the text to get drawn on top of the plot.

If you are just using gsn_text, however, you have to make sure you draw the plot first, and then the text.

Here's how your code might look if you use gsn_add_text:

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
begin
 f = addfile ("$NCARG_ROOT/lib/ncarg/data/cdf/uv300.nc","r")
 u = f->U

 wks = gsn_open_wks ("x11","xy")

 res = True
 res@tmXMinorGrid = True
 res@gsnDraw = False
 res@gsnFrame = False
 plot = gsn_csm_xy (wks,u&lat,u(0,:,{82}),res)

 txres = True
 txres@txFontHeightF = 0.03
 txres@txPerimOn = True
 txres@txBackgroundFillColor = "red"
 txid = gsn_add_text(wks,plot,"hello world",0,20,txres)

 draw(plot) ; Drawing "plot" will also draw attached text string.
 frame(wks)
end

Here's how it should look if you just use gsn_text:

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
begin
;---read in data
 f = addfile ("$NCARG_ROOT/lib/ncarg/data/cdf/uv300.nc","r")
 u = f->U

 wks = gsn_open_wks ("x11","xy")

 res = True
 res@tmXMinorGrid = True
 res@gsnFrame = False ; >eave gsnDraw alone!
 plot = gsn_csm_xy (wks,u&lat,u(0,:,{82}),res) ; Draw plot, don't advance frame

 txres = True
 txres@txFontHeightF = 0.03
 txres@txPerimOn = True
 txres@txBackgroundFillColor = "red"
 gsn_text(wks,plot,"hello world",0,20,txres) ; Text will be drawn on plot

 frame(wks)
end

On Mar 21, 2013, at 11:05 AM, Rosemarie Drummond wrote:

> Unfortunately this doesn 't seem to solve the problem. The grid lines
> seem to go on last.
> the data in the plot is shown with 3 sets of polymarkers which are
> affected by the value of tfPolyDrawOrder but even if I set it to
> PostDraw in the resources for a particular set of markers, the grid goes
> over them.
> Rosemarie
>
> On 21/03/2013 1:20 PM, Adam Phillips wrote:
>> Hi Rosemarie,
>> I'm not 100% sure on this but try setting tfPolyDrawOrder = "PostDraw"
>> in your text resource list. If that does not work let ncl-talk know..
>> http://www.ncl.ucar.edu/Applications/draworder.shtml
>> Adam
>>
>> On 03/21/2013 09:56 AM, Rosemarie Drummond wrote:
>>> I am making an xy-plot with gsn_csm_xy and I have tmXMinorGrid=True
>>> Later I add text in a box using txPerimOn=True and
>>> txBackgroundFillColor="red"
>>>
>>> Is it possible for the text box to cover the gridlines so that they do
>>> not show through?
>>> Thanks
>>> Rosemarie
>>>
>
>
> --
> Dr Rosemarie Drummond
> rmarie@atmosp.physics.utoronto.ca
>
> _______________________________________________
> 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 Fri Mar 22 09:58:25 2013

This archive was generated by hypermail 2.1.8 : Fri Mar 22 2013 - 16:45:18 MDT