Plotting MajorGridlines on XY plot

From: Vollaro, David <dvollaro_at_nyahnyahspammersnyahnyah>
Date: Fri Oct 25 2013 - 09:36:11 MDT


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!

; 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"
; read in data
 f = addfile ("$NCARG_ROOT/lib/ncarg/data/cdf/","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

ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
Received on Fri Oct 25 09:36:22 2013

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