[ncl-talk] XY Plot with Precip vs Time

Melissa Lazenby M.Lazenby at sussex.ac.uk
Wed Nov 16 04:37:53 MST 2022


Dear All NCL Users

I am having trouble displaying my x-axis correctly for an XY plot with precip anomalies vs time.
Below is the figure and code:
[cid:8e9bc557-0b88-48b3-9336-a13f3597a8c7]

I just would like to have my x-axis represent my time data which is in years from 1856-1890.

Any help would be greatly appreciated.

;************************************************
; Concepts illustrated:
;   - Drawing a xyplot
;************************************************
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
;************************************************
begin
;************************************************
; variable and file handling
;************************************************
  in  = addfile("/mnt/geog/ml382/ml382_sals000408_home_dir/melsicz/mpwapwa/ENSMEAN/pr_Amon_ENSMEAN_historical_mpwapwa_1856-1890_NDJFMA_NEW_ANOM_YMONMEAN.nc","r")

 pr = in->pr(:,0,:,:)

 print(pr)

;************************************************
; plotting
;************************************************
  wks  = gsn_open_wks("X11","Figure_Mpwapwa_20CR")                 ; Opens a ps file

  res                          = True
  res at gsnMaximize              = True
  res at tiXAxisString             = "Years 1856-1890 (NDJFMA)"       ; x-axis label
  res at tiYAxisString             = "Precipitation Anomaly"     ; y-axis label
   res at xyLineLabelsOn            = True              ; no contour line labels
  ;res at trXMinF                   =  1856              ; min level
  ;res at trXMaxF                   =  1890            ; max level
  res at xyLineThicknessF          = 4.0
   res at lgLineThicknessF           = 2.0

  res at gsnDraw             = False              ; do not draw the plot
  res at gsnFrame            = False
  ;res at pmLegendDisplayMode    = "Always"   ; Display a legend.

  res at pmLegendParallelPosF = 1.25 ; move units right
  res at pmLegendOrthogonalPosF = -0.9 ; move units down
  res at lgBoxMinorExtentF       = 0.3
  res at pmLegendWidthF          = 0.1
  res at lgLabelFontHeightF      = 0.015     ; Change the font size
  res at pmLegendHeightF         = 0.2

res at gsnXYBarChart = True
 res at xyLineColors           = (/"blue", "red"/)
res at tiMainString = "CMIP5 ENSMEAN Precipitation Anomalies over Mpwapwa"
 res at gsnYRefLine  = 0.              ; reference line


plot1=gsn_csm_xy(wks,pr&time,pr(:,0,0),res)

 draw(plot1)
 frame(wks)

end

Kindest Regards
Melissa

Dr. Melissa Lazenby
Lecturer in Climate Change
Department of Geography
Chichester 1 C150
University of Sussex

"Education is the most powerful weapon which you can use to change the world" Nelson Mandela

[cid:63fbacc1-0818-44dc-b058-c7360bbf877b]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20221116/ad394b8e/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 57655 bytes
Desc: image.png
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20221116/ad394b8e/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Outlook-v1qhdcap.png
Type: image/png
Size: 24937 bytes
Desc: Outlook-v1qhdcap.png
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20221116/ad394b8e/attachment-0001.png>


More information about the ncl-talk mailing list