Re: Plotting MajorGridlines on XY plot

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Fri Oct 25 2013 - 11:52:49 MDT

Hi Dave,
Thanks for sending a simple example to test. I have a work around
solution for you: Use gsnYRefLine and its associated resources as
opposed to the tm*Grid resources.
Try this:

   res = True ; plot mods desired
   res@gsnDraw = False
   res@gsnFrame = False
   res@tiMainString = "Basic XY plot" ; add title
   res@xyLineColors = "blue" ;added djv
   res@xyLineThicknesses = 2.0 ;added djv
   res@xyCurveDrawOrder = "PostDraw" ;added djv
   res@gsnYRefLine = ispan(0,40,10)
   res@gsnYRefLineColor = "green"
   res@gsnYRefLineThicknessF = 2.0

   plot1 = gsn_csm_xy (wks,u&lat,u(0,:,{82}),res) ;added djv
   res@xyLineColors = "red" ;added djv
   plot2 = gsn_csm_xy (wks,u&lat,u(0,:,{82}),res) ;added djv
   overlay(plot1,plot2) ;added djv
   draw (plot1) ;added djv
   frame(wks) ;added djv
end

I think this is case where the resource needed to set the draw order of
the tm grid lines does not exist. However, the gsnYRefLine resource can
serve as a suitable substitute. See:
http://www.ncl.ucar.edu/Document/Graphics/Resources/gsn.shtml#gsnYRefLine

If that doesn't work for you please respond to ncl-talk.
Adam

On 10/25/2013 09:36 AM, Vollaro, David wrote:
> Hi,
>
> I am trying to create a xy plot with major grid lines on the Y-axis
> using tmYMajorGrid. Unfortunately I cannot get the major lines to be
> plotted first(ie. behind the curve). I have taken the simple xyplot
> example(attached) and modified it to plot with majorgridlines. I have
> tried changing the curve draw order and using overlay to no avail. The
> sample output from the script is:
>
> The four plots are
> 1. basic xyplot from NCL page
> 2. basic plot with majorgrid
> 3. redline plot w/o majorgrid
> 4. redline plot overlayed onto majorgridplot
>
> In the overlay plot, the redline is overlayed, but grid still comes out on top.
> I am running version 6.1.2. Any help would be appreciated. Thanks!
>
> Dave
> ----------------------------------------------------------------------
> ; xy_1.ncl
> ;
> ; Concepts illustrated:
> ; - Drawing a black-and-white XY plot
> ;
> ;************************************************
> 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 ; get u data
> ;************************************************
> ; plotting parameters
> ;************************************************
> wks = gsn_open_wks ("ps","xy") ; open workstation
>
> res = True ; plot mods desired
> res@tiMainString = "Basic XY plot" ; add title
> res@xyLineColors = "blue" ;added djv
> plot = gsn_csm_xy (wks,u&lat,u(0,:,{82}),res) ; create plot
> res@xyLineThicknesses = 2.0 ;added djv
> res@tmYMajorGridLineColor = "green" ;added djv
> res@tmYMajorGridThicknessF = 2.0 ;added djv
> res@tmYMajorGrid = True ;added djv
> res@xyCurveDrawOrder = "PostDraw" ;added djv
>
> plot1 = gsn_csm_xy (wks,u&lat,u(0,:,{82}),res) ;added djv
> res@tmYMajorGrid = False ;added djv
> res@xyLineColors = "red" ;added djv
> plot2 = gsn_csm_xy (wks,u&lat,u(0,:,{82}),res) ;added djv
> overlay(plot1,plot2) ;added djv
> draw (plot1) ;added djv
> frame(wks) ;added djv
> end
>
> ----------------------------------------------------------------------
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-- 
______________________________________________________________
Adam Phillips                                asphilli@ucar.edu
NCAR/Climate and Global Dynamics Division       (303) 497-1726
P.O. Box 3000				
Boulder, CO 80307-3000    http://www.cgd.ucar.edu/cas/asphilli
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Oct 25 11:52:57 2013

This archive was generated by hypermail 2.1.8 : Fri Nov 01 2013 - 08:58:14 MDT