<div dir="ltr">Dhirendra,<br><br>First, a couple of NCL tips:<br><br>1) <div class="gmail_default" style="font-size:small;display:inline">You don't need to use a "do" loop to do simple array arithmetic. You can replace the following code:</div><br><br><font face="monospace, monospace"> <div class="gmail_default" style="font-size:small;display:inline"> </div>dateF = new (dimDate, float) <br> do n=0,dimDate-1 <br> yyyy = date(n)/100 <br> mon = date(n)-yyyy*100<br> dateF(n) = tofloat(yyyy + (mon-1)/12.) <br> end do<br></font><br><div class="gmail_default" style="font-size:small;display:inline">with:</div><br><br><font face="monospace, monospace"> yyyy = date/100 <br> mon = date-yyyy*100<br> dateF = tofloat(yyyy + (mon-1)/12.) </font><br><br>2) We have a function that converts YYYYMM to YYYY.frac, so the above code can be replaced with<div class="gmail_default" style="font-size:small;display:inline"> one line:</div><br><br><font face="monospace, monospace"> dateF = yyyymm_to_yyyyfrac(date,0.0)</font><div><div class="gmail_default" style="font-size:small"><div class="gmail_default"><div class="gmail_default" style="font-size:12.8px"><br></div></div></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">The values on your X axis look suspicious to me, as they go from around 7000 to over 10000. Are these really your year values? Did you look at the original "date" variable to make sure these values are actually YYYYMM?</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><font face="monospace, monospace">printVarSummary(date)</font></div><div class="gmail_default" style="font-size:small"><font face="monospace, monospace">printMinMax(date)</font></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">You should also do:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><font face="monospace, monospace">print(date) </font></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">to see what all the numbers look like.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">To get nice labels on a time axis, I highly recommend the use of the time_axis_labels function:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default"><a href="http://www.ncl.ucar.edu/Document/Functions/User_contributed/time_axis_labels.shtml">http://www.ncl.ucar.edu/Document/Functions/User_contributed/time_axis_labels.shtml</a><br></div><div class="gmail_default"><br></div><div class="gmail_default">You have lots of options for how to format your labels.</div><div class="gmail_default"><br></div><div class="gmail_default">You can see some examples of how to use this at:</div><div class="gmail_default"><br></div><div class="gmail_default"><a href="http://www.ncl.ucar.edu/Applications/time_labels.shtml">http://www.ncl.ucar.edu/Applications/time_labels.shtml</a><br></div><div class="gmail_default"><br></div><div class="gmail_default">In particular, look at time_labels_4.ncl. This shows how to plot time data that is in a YYYYMM format. I'm not sure your time is in this format, but hopefully the above page will give you enough information to format your X labels the way you want them.</div><div class="gmail_default"><br></div><div class="gmail_default">--Mary</div><div class="gmail_default"><br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 5, 2017 at 8:09 AM, Dhirendra Kumar <span dir="ltr"><<a href="mailto:dhirendra.cub@gmail.com" target="_blank">dhirendra.cub@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif"><div class="gmail_default" style="font-size:12.8px">Hi</div><div class="gmail_default" style="font-size:12.8px"><br></div><div class="gmail_default" style="font-size:12.8px">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.</div><div class="gmail_default" style="font-size:12.8px"><br></div><div class="gmail_default" style="font-size:12.8px">Would appreciate if anybody could help...</div><div class="gmail_default" style="font-size:12.8px">the script is as following- </div><div class="gmail_default" style="font-size:12.8px"><br></div><div class="gmail_default" style="font-family:arial,sans-serif;font-size:12.8px"><div class="gmail_default"><font face="georgia, serif">begin</font></div><div class="gmail_default"><font face="georgia, serif"> f = addfile ("<a href="http://std_tim_anomaly.nc/" target="_blank">std_tim_anomaly.nc</a>", "r") ; add file</font></div><div class="gmail_default"><font face="georgia, serif"> date = f->time</font></div><div class="gmail_default"><font face="georgia, serif"> printVarSummary(date)</font></div><div class="gmail_default"><font face="georgia, serif"> precip= f->tp(:,0,0)</font></div><div class="gmail_default"><font face="georgia, serif"> printVarSummary(precip)</font></div><div class="gmail_default"><font face="georgia, serif"> </font></div><div class="gmail_default"><font face="georgia, serif"> dimDate = dimsizes(date) ; number of dates</font></div><div class="gmail_default"><font face="georgia, serif"><br></font></div><div class="gmail_default"><font face="georgia, serif">; convert integer YYYYMM to float</font></div><div class="gmail_default"><font face="georgia, serif"><br></font></div><div class="gmail_default"><font face="georgia, serif"> dateF = new (dimDate, float) </font></div><div class="gmail_default"><font face="georgia, serif"> do n=0,dimDate-1 </font></div><div class="gmail_default"><font face="georgia, serif"> yyyy = date(n)/100 </font></div><div class="gmail_default"><font face="georgia, serif"> mon = date(n)-yyyy*100</font></div><div class="gmail_default"><font face="georgia, serif"> dateF(n) = tofloat(yyyy + (mon-1)/12.) </font></div><div class="gmail_default"><font face="georgia, serif"> end do</font></div><div class="gmail_default"><font face="georgia, serif"><br></font></div><div class="gmail_default"><font face="georgia, serif">;*****************************<wbr>****</font></div><div class="gmail_default"><font face="georgia, serif">; create plot</font></div><div class="gmail_default"><font face="georgia, serif">;*****************************<wbr>***</font></div><div class="gmail_default"><font face="georgia, serif"> wks = gsn_open_wks ("ps", "bar" ) ; send graphics to PS file</font></div><div class="gmail_default"><font face="georgia, serif"> res = True ; plot mods desired</font></div><div class="gmail_default"><font face="georgia, serif"> res@gsnScale = True </font></div><div class="gmail_default"><font face="georgia, serif"> </font></div><div class="gmail_default"><font face="georgia, serif">; these four resources allow the user to stretch the plot size, and</font></div><div class="gmail_default"><font face="georgia, serif">; decide exactly where on the page to draw it.</font></div><div class="gmail_default"><font face="georgia, serif"> </font></div><div class="gmail_default"><font face="georgia, serif"> res@vpXF = 0.10 ; In page coordinates, where to start</font></div><div class="gmail_default"><font face="georgia, serif"> res@vpYF = 0.75 ; the plot</font></div><div class="gmail_default"><font face="georgia, serif"> res@vpHeightF = 0.43 ; Changes the aspect ratio</font></div><div class="gmail_default"><font face="georgia, serif"> res@vpWidthF = 0.85</font></div><div class="gmail_default"><font face="georgia, serif"> </font></div><div class="gmail_default"><font face="georgia, serif"> res@trYMinF = -3.0 ; min value on y-axis</font></div><div class="gmail_default"><font face="georgia, serif"> res@trYMaxF = 3.0 ; max value on y-axis</font></div><div class="gmail_default"><font face="georgia, serif"> </font></div><div class="gmail_default"><font face="georgia, serif"> res@tiYAxisString = "Anomalies" ; y-axis label </font></div><div class="gmail_default"><font face="georgia, serif">; this resource changes a regular line plot to a bar chart</font></div><div class="gmail_default"><font face="georgia, serif"> res@gsnXYBarChart = True ; create bar chart </font></div><div class="gmail_default"><font face="georgia, serif">; this resource is required to get bars above and below a reference line</font></div><div class="gmail_default"><font face="georgia, serif"> res@gsnYRefLine = 0. ; reference line </font></div><div class="gmail_default"><font face="georgia, serif"> res@gsnXYBarChart = True ; create bar chart </font></div><div class="gmail_default"><font face="georgia, serif"> res@gsnAboveYRefLineColor = "red" ; above ref line fill red</font></div><div class="gmail_default"><font face="georgia, serif"> res@gsnBelowYRefLineColor = "blue" ; below ref line fill blue</font></div><div class="gmail_default"><font face="georgia, serif"> res@gsnXYBarChartBarWidth = 24.0</font></div><div class="gmail_default"><font face="georgia, serif"> plot = gsn_csm_xy (wks,dateF(::),precip,res)</font></div><div class="gmail_default"><font face="georgia, serif">end</font></div><div class="gmail_default"><font face="georgia, serif"><br></font></div><div class="gmail_default"><font face="georgia, serif"><img src="cid:ii_1596f07b17109416" alt="Inline image 1" width="524" height="285" class="m_4754589073469523680gmail-CToWUd m_4754589073469523680gmail-a6T"></font><span style="font-family:georgia,serif">this is the plot which is being created.</span><font face="georgia, serif"><br></font></div><div class="gmail_default"><font face="georgia, serif"><br></font></div><div class="gmail_default"><font face="georgia, serif">Thanks in anticipation.</font></div></div></div><span class="HOEnZb"><font color="#888888"><div><br></div>-- <br><div class="m_4754589073469523680gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">==============================<wbr>==========</div><div dir="ltr">Dhirendra Kumar<div>PhD Student<br></div><div>School of Environmental Sciences, JNU<br></div><div>New Delhi (India)</div><div>Contact: <font face="comic sans ms, sans-serif"><a href="tel:+91%2099107%2078043" value="+919910778043" target="_blank">+91 9910778043</a></font></div><div>Alternate email: <a href="mailto:dhirendra.cub@outlook.com" target="_blank">dhirendra.cub@outlook.com</a></div><div>==============================<wbr>===========</div></div></div></div></div></div></div></div></div></div></div>
</font></span></div>
<br>______________________________<wbr>_________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/<wbr>mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>