Re: labelled grid lines

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon, 12 Jun 2006 07:17:54 -0600 (MDT)

On Sun, 11 Jun 2006, Hamish Struthers wrote:

>
> Dear NCL
>
> Is it possible to draw labelled grid lines (labelled with latitude or
> longitude), like in the maps attached to this email?
>
> Thanks
> Hamish
>

Hi Hamish,

There is no way to automatically do this with NCL. You need to label
the lines yourself using something like gsn_add_text. Here's
a simple example:

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

begin

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

   res = True

   res@gsnFrame = False ; Turn off draw and frame
   res@gsnDraw = False ; so we can add labels.

   res@mpGridAndLimbOn = True ; Turn on map grid lines and
   res@mpGridLineDashPattern = 2 ; change pattern and color.
   res@mpGridSpacingF = 30

   map = gsn_csm_map(wks,res) ; Create map.

   labels = new(3,graphic) ; Create array to hold labels.

   txres = True ; Set some text resources.
   txres@txFontColor = "red"
   txres@txFontHeightF = 0.015
; txres@txBackgroundFillColor = 0 ; Set background of text to white.
;
; Add the labels to the plot. By doing this, they will get resized
; appropriately if the plot is resized.
;
   labels(0) = gsn_add_text(wks,map,"150E", 150,-15,txres)
   labels(1) = gsn_add_text(wks,map, "30N", -75, 30,txres)
   labels(2) = gsn_add_text(wks,map,"120W",-120,-45,txres)

   draw(map) ; Now draw map and advance frame.
   frame(wks) ; The labels will also get drawn.

end
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Jun 12 2006 - 07:17:54 MDT

This archive was generated by hypermail 2.2.0 : Mon Jun 12 2006 - 07:29:19 MDT