scatter plots

From: Sara Rauscher (rauscher AT iri.columbia.edu)
Date: Thu Jun 16 2005 - 10:23:27 MDT


Hi,

I have a question about scatter plots. Is it possible to control the
color of the markers by the x-axis value? I have a time series of rainy
season onset and withdrawal dates for a 22-year period (one per year),
and I want to color them by year (binned into El Nino years, La Nina
years, and neutral years).

I attached the script I have been using (ne.scatter.enso.ncl), but right
now all of the markers are black. I'd like to use the "enso" array (one
value for each year) to color the markers.

Thanks,
sara

-- 
Dr. Sara A. Rauscher, Staff Associate
International Research Institute for Climate Prediction
Lamont Doherty Earth Observatory of Columbia University
101 Monell Building
PO Box 1000
Palisades NY 10964-8000
Phone: 845-680-4515
Fax: 845-680-4864

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

begin

;************************************************ ; read in data ;************************************************

nnrp = addfile ("../data/8203/onset.grell.nnrp.nc","r") echam = addfile ("../data/8203/onset.grell.echam.nc","r") sam = addfile ("../data/8203/onset.sam.8203.nc","r") gcm = addfile ("../data/8203/onset.echamgcm.8203.nc","r") f1 = addfile("/mstore/iri/modelling/rauscher/SAM/sam.cdf", "r") ; set values year1 = 1982 ;first year of sims year2 = 2003 ;end year of sims ; calcs based on set values ny = year2 - year1 y1 = year1 + 1 model = new((/2/),float) do i=0,dimsizes(model)-1 model(i) = i end do

onset = new((/dimsizes(model),ny/),float) year = new((/ny/), float) do i=0,ny-1 year(i) = i+year1+1 end do

onset!0="model" onset&model = model onset!1="year" onset&year = year

;enso array (el nin0 = 1, neutral = 0, la nina = 1) ;this is a first guess array and not necessarily the correct event years (jfm +1 of event) ;array of values for years 1983-2002 enso = (/1,0,-1,0,1,0,-1,0,0,1,0,0,1,-1,0,1,-1,-1,-1,0,0/)

onset(0,:) = (/sam->aons(2,:)/) onset(1,:) = (/sam->awit(2,:)/) ;************************************************ ; plotting parameters ;************************************************ wks = gsn_open_wks ("ps","northeast") ; open workstation

res = True ; plot mods desired res@tiMainString = "Northeast Onset and Withdrawal" ; add title res@trYMinF = 124 res@trYMaxF = 365 res@trXMinF =year1 res@trXMaxF =year2 res@tiXAxisString = "Year" ; xaxis string res@tiYAxisString = "Onset and Withdrawal Date" ; yaxis string res@xyMarkLineModes = (/"Markers","Markers"/) res@xyMarkerSizeF = 0.011 res@xyMarkers = (/16,16/) res@xyMarkerColors = (/"black","black"/) res@tmXBOn = True ; have tick marks res@tmXBMode = "Explicit" ; label independently res@tmXBValues = (/1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003/) res@tmXBLabels = (/"82-83","83-84","84-85","85-86","86-87","87-88","88-89","89-90","90-91","91-92","92-93","93-94","94-95","95-96","96-97","97-98","98-99","99-00","00-01","01-02","02-03"/)

res@tmYLOn = True res@tmYLLabelsOn = True res@tmYLMinorOn = False res@tmYLMode = "Explicit" res@tmYLValues = (/124,154,185,216,244,275,305,336/) res@tmYLLabels = (/"Nov", "Dec", "Jan", "Feb", "Mar", "Apr", "May", "Jun"/)

;font stuff res@tiMainFont = 21 res@tiXAxisFont = 21 res@tiYAxisFont = 21

res@tmXBLabelFont = 21 res@tmXBLabelFontHeightF = 0.017 res@tmXBLabelAngleF = 90 res@tmXBLabelJust = "CenterLeft" res@tmYLLabelFont = 21 res@tmYLLabelFontHeightF = 0.017

plot = gsn_csm_xy (wks,onset&year,onset(:,:),res) ; create plot

end

_______________________________________________ ncl-talk mailing list ncl-talk@ucar.edu http://mailman.ucar.edu/mailman/listinfo/ncl-talk



This archive was generated by hypermail 2b29 : Mon Jun 20 2005 - 08:43:13 MDT