Re: How to Replace default Y-axis labels and tickmarks ?

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Thu Sep 05 2013 - 10:14:30 MDT

Hi Helen,
The range of values in the Y-coordinate variable of tdiff must match up
with the range of values that you are specifying in tmYLValues. Thus, a
simple example:

tdiff = new((/10,20/),"float")
tdiff!0 = "lon"
tdiff&lon = ispan(0,90,10)
tdiff!1 = "time"
tdiff&time = ispan(1,20,1)

res = True...
res@tmYLMode = "Explicit"
res@tmYLValues = (/5,10,15,20/)
res@tmYLLabels = (/"5E","10E","15E","20E"/)
...
plot = gsn_csm_contour(wks,tdiff,res)

The above YL label coding should work, as the range of tmYLValues (from
5-20) matches the range of tdiff&time (from 1-20).. If those two ranges
do not overlap you will not get any labels or tickmarks whatsoever.

Thus you either have to conform your tmYLValues to be in the same range
as tdiff&time, or you need to alter your tdiff&time to be in the same
range as tmYLValues.

Hope that helps. If you have any further questions please respond to
ncl-talk.
Adam

On 09/04/2013 11:36 PM, Helen Parish wrote:
> It helped a little to not set tmLabelAutoStride, in that a core file
> was no longer produced.
>
> However, a persistent problem is that I need to find a way to insert
> different values on the axis from the strict range within the data. I
> want to convert the numbers on the axis from days to years, and make
> these values start at zero relative to a given date. So the numbers
> which come out of the data are not the numbers I would like to be
> displayed on the Y-axis, which I would like to customize to be more
> intelligible. Does anyone know how to do this ?.
>
> I am trying to plot the variable tdiff, as shown in the script below,
> and defined at the bottom of the page. I want to plot tdiff as a
> function of time and longitude in a Hovmuller type plot. So I want to
> plot values on the y-axis that are derived from the time values, but
> which are different from those time values themselves. Right now, I
> can either get those original time values on the y-axis, or no numbers
> at all on the y-axis, but I cannot enter the values I want to put on
> the y-axis.
>
> Does anyone know how I can do this ?.
>
> Thanks,
> Helen.
>
>
>
>
>
> On Sep 4, 2013, at 8:04 AM, Mary Haley wrote:
>
>> Helen,
>>
>> It looks like you are setting the tickmark resources correctly.
>>
>> Are you getting any kind of warning or error at all?
>>
>> You have to be sure that the values you use for tmYLValues correspond
>> with the range of the Y aixs.
>>
>> Also, don't set tmLabelAutoStride when you are in "explicit" mode.
>>
>> See attached example and data file.
>>
>> --Mary
>>
>>
>>
>> On Sep 4, 2013, at 5:06 AM, Helen Parish wrote:
>>
>> > I am trying to modify the Y-axis label and tickmarks from the default
>> > for a Hovmuller style plot, but cannot find a way to get it to replace
>> > the default label and tickmarks with my chosen explicit values. I can
>> > either eliminate the Y label and tick marks completely, or have both
>> > labels appear together. Also, if tick marks are not completely
>> > eliminated, both sets of tickmarks are present and the core is dumped.
>> > I have tried using both gsn_csm_hov and gsn_csm_contour, but the
>> > default Y-axis values seem to be forced in both cases.
>> >
>> > Does anyone know how I can replace the default Y-axis label and
>> > tickmarks ?.
>> >
>> > I enclose the part of the script which creates the plot below, and
>> > below that I enclose summaries of the variables which are used.
>> >
>> > Thanks,
>> > Helen.
>> >
>> >
>> >
>> > ;***********************
>> > ; Create Plot
>> > ;***********************
>> >
>> > res = True
>> >
>> > res@gsnLeftString = ""
>> > res@gsnCenterString = "Hovmuller Plot T-Ttime-mean"
>> > res@gsnRightString = ""
>> >
>> > res@cnFillOn = True
>> > res@lbLabelAutoStride = True
>> > res@gsnMaximize = True ; if [ps, eps, pdf] make large
>> > res@gsnSpreadColors = True ; span color map
>> > res@cnLineLabelsOn = False ; Turn off contour line labels
>> > res@cnInfoLabelOn = False ; Turn off informational label
>> >
>> > time3 = time2
>> > time3 = (time2-36155.0)/365.0
>> > timlabel = time3
>> >
>> > timlabel(0) = time3(0)
>> > timlabel(1) = time3(10)
>> > timlabel(2) = time3(20)
>> > timlabel(3) = time3(30)
>> > timlabel(4) = time3(40)
>> > timlabel(5) = time3(51)
>> >
>> > labsy = (/"0.0","10.0","20.0","30.0","40.0","50.0"/)
>> > res@tmYLMode = "Explicit" ; explicit labels
>> > res@tmYLValues = timlabel(0:5) ; location of labels
>> > res@tmYLLabels = labsy ; labels themselves
>> > res@tmLabelAutoStride = True ; nice stride on
>> > labels
>> >
>> > res@tmXBMode = "Manual"
>> > res@tmXBTickStartF = 0
>> > res@tmXBTickEndF = 50
>> > res@tmXBTickSpacingF= 5
>> >
>> > res@tiXAxisString = "Longitude (degrees)"
>> > res@tiYAxisString = "Time (years from year 100)"
>> >
>> > res@pmTitleZone = 3
>> > res@pmLabelBarOrthogonalPosF = 0.05
>> >
>> > res@lbTitleOn = True
>> > res@lbTitleDirection = "Across" ; title direction
>> > res@lbTitlePosition = "Right"
>> > res@lbTitleString = "(K)"
>> > res@lbTitleFontHeightF = 0.02
>> > res@lbTitleOffsetF = 0.0
>> >
>> > plot = gsn_csm_contour(wks, tdiff(:,19,95,:), res ) ;
>> > (time,lon)
>> >
>> > end
>> >
>> >
>> >
>> > Variable: tdiff
>> > Type: float
>> > Total Size: 575078400 bytes
>> > 143769600 values
>> > Number of Dimensions: 4
>> > Dimensions and sizes: [time | 52] x [lev | 50] x [lat | 192] x [lon |
>> > 288]
>> > Coordinates:
>> > time: [36166.66666666666..54833.33333333334]
>> > lev: [0.03554912016..91942.93428213599]
>> > lat: [ -90.. 90]
>> > lon: [ 0..358.75]
>> > Number Of Attributes: 3
>> > cell_methods : time: mean
>> > long_name : Temperature
>> > units : K
>> >
>> >
>> > Variable: time2
>> > Type: double
>> > Total Size: 416 bytes
>> > 52 values
>> > Number of Dimensions: 1
>> > Dimensions and sizes: [time | 52]
>> > Coordinates:
>> > time: [36166.66666666666..54833.33333333334]
>> > Number Of Attributes: 4
>> > long_name : time
>> > units : days since 0001-01-01 00:00:00
>> > calendar : noleap
>> > bounds : time_bnds
>> >
>> >
>> > Variable: time3
>> > Type: double
>> > Total Size: 416 bytes
>> > 52 values
>> > Number of Dimensions: 1
>> > Dimensions and sizes: [time | 52]
>> > Coordinates:
>> > time: [36166.66666666666..54833.33333333334]
>> > Number Of Attributes: 4
>> > bounds : time_bnds
>> > calendar : noleap
>> > units : days since 0001-01-01 00:00:00
>> > long_name : time
>> >
>> >
>> > _______________________________________________
>> > ncl-talk mailing list
>> > List instructions, subscriber options, unsubscribe:
>> > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>> <hov.ncl><chi200_ud_smooth.nc>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-- 
______________________________________________________________
Adam Phillips                                asphilli@ucar.edu
NCAR/Climate and Global Dynamics Division       (303) 497-1726
P.O. Box 3000				
Boulder, CO 80307-3000    http://www.cgd.ucar.edu/cas/asphilli

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Sep 5 10:14:44 2013

This archive was generated by hypermail 2.1.8 : Mon Sep 16 2013 - 13:43:52 MDT