Re: axes for contour plot

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Tue Aug 27 2013 - 16:03:12 MDT

Bithi,

See example "tm_2.ncl" at:

http://www.ncl.ucar.edu/Applications/tickmarks.shtml

The code of interest is:

  res@tmXBMode = "Explicit"
  res@tmXBValues = (/1950,1960,1970,1980,1990,2000,2005/)
  res@tmXBLabels = "" + res@tmXBValues

You'll need to modify the above to use something like:

  res@tmXBMode = "Explicit"
  res@tmXBValues = ispan(1951,1980,1)
  res@tmXBLabels = "" + res@tmXBValues ; using ' "" + ' is a trick to convert integers to strings

It will be the same idea for the Y axis:

  res@tmYLMode = "Explicit"
  res@tmYLValues = ispan(1,12,1)
  res@tmYLLabels = (/"Jan","Feb",…,"Dec"/)

I don't know what your Y axis values look like, but if they go from 0 to 11 and not 1 to 12, then you will need:

  res@tmYLValues = ispan(0,11,1)

I think you can use the "month_name" function to generate the names "Jan", "Feb", etc:

  res@tmYLLabels = month_name(0)

You will have to be sure "contributed.ncl" is loaded at the top of your script:

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

--Mary

On Aug 27, 2013, at 3:42 PM, Bithi De wrote:

> Hi All,
> I want to make a contour plot for an array(12,30) with 12 months and
> 30 years data. How can I apply Jan-Dec for months and say 1951-1980
> for years the axis?
> Now I am having only 1-12 for months and 1-30 for years on the axis.
>
> my code is like this:
>
> wks = gsn_open_wks ("X11","QTano")
> gsn_define_colormap(wks,"BlueRed")
>
>
> res = True
> res@cnFillOn = True
> res@cnLevelSelectionMode= "ManualLevels"
> res@cnMinLevelValF = -0.3
> res@cnMaxLevelValF = .25
> res@cnLinesOn = False
> res@gsnSpreadColors = True
>
> res@lbLabelAutoStride = True
> res@gsnMaximize = True
> res@tiYAxisString = "Month (Jan to Dec)"
> res@tiXAxisString = "Year (1951-2080)"
>
> month =(/1,2,3,4,5,6,7,8,9,10,11,12/)
> plot = gsn_csm_contour(wks,MTano,res)
>
>
> Thanks in advance.
> Bithi
>
> --
>
>
> Bithi De
>
> Graduate Student , Research Assistant
> International Arctic Research Center , University of Alaska Fairbanks
> Fairbanks , Alaska -99775
> USA
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Aug 27 16:03:22 2013

This archive was generated by hypermail 2.1.8 : Fri Aug 30 2013 - 14:04:57 MDT