[ncl-talk] can not create year labels for x axis
Dhirendra Kumar
dhirendra.cub at gmail.com
Thu Jan 5 08:09:42 MST 2017
Hi
I am trying to plot an nc file having anomaly time series for the JJAS
season. I have tried to follow the sample scripts over the NCL web
resource, but could not succeed in getting the correct labels of time
(year) on the X axis.
Would appreciate if anybody could help...
the script is as following-
begin
f = addfile ("std_tim_anomaly.nc", "r") ; add file
date = f->time
printVarSummary(date)
precip= f->tp(:,0,0)
printVarSummary(precip)
dimDate = dimsizes(date) ; number of dates
; convert integer YYYYMM to float
dateF = new (dimDate, float)
do n=0,dimDate-1
yyyy = date(n)/100
mon = date(n)-yyyy*100
dateF(n) = tofloat(yyyy + (mon-1)/12.)
end do
;*********************************
; create plot
;********************************
wks = gsn_open_wks ("ps", "bar" ) ; send graphics to PS file
res = True ; plot mods desired
res at gsnScale = True
; these four resources allow the user to stretch the plot size, and
; decide exactly where on the page to draw it.
res at vpXF = 0.10 ; In page coordinates, where to start
res at vpYF = 0.75 ; the plot
res at vpHeightF = 0.43 ; Changes the aspect ratio
res at vpWidthF = 0.85
res at trYMinF = -3.0 ; min value on y-axis
res at trYMaxF = 3.0 ; max value on y-axis
res at tiYAxisString = "Anomalies" ; y-axis label
; this resource changes a regular line plot to a bar chart
res at gsnXYBarChart = True ; create bar chart
; this resource is required to get bars above and below a reference line
res at gsnYRefLine = 0. ; reference line
res at gsnXYBarChart = True ; create bar chart
res at gsnAboveYRefLineColor = "red" ; above ref line fill red
res at gsnBelowYRefLineColor = "blue" ; below ref line fill blue
res at gsnXYBarChartBarWidth = 24.0
plot = gsn_csm_xy (wks,dateF(::),precip,res)
end
[image: Inline image 1]this is the plot which is being created.
Thanks in anticipation.
--
========================================
Dhirendra Kumar
PhD Student
School of Environmental Sciences, JNU
New Delhi (India)
Contact: +91 9910778043
Alternate email: dhirendra.cub at outlook.com
=========================================
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170105/3b888c84/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 13157 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170105/3b888c84/attachment.png
More information about the ncl-talk
mailing list