Re: X Axis Labels

From: Cory Wolff <cwolff_at_nyahnyahspammersnyahnyah>
Date: Thu Jun 02 2011 - 14:54:53 MDT

Thanks to Adam for helping me solve this offline. Here is what ended up
making it work for my use:

You were right to suspect that the issue is with your time coordinate
variable being a string. NCL doesn't understand how to lay out the
x-axis based on a string array. The x-axis is based off of the 1st
(y-axis is based off the 0th) coordinate dimension of the array that is
passed into the plotting function. So when NCL realized that the array
that it is suppose to use for the x-axis is a string, it spits out an
error message:

warning:_NhlCreateSplineCoordApprox: Attempt to create spline
approximation for X axis failed: consider adjusting trXTensionF value
warning:IrTransInitialize: error creating spline approximation for
trXCoordPoints; defaulting to linear

and _replaces_ your time string array with an integer array starting at
0 and continuing until dimsizes(ref&time)-1. This results in a need for
us to modify the XBValues resource appropriately now that it is an
integer array starting at 0:
  tt = 500 ; how often should XBLabels appear?
  res@tmXBMode = "Explicit"
  res@tmXBValues = ispan(0,2408,tt) ; <-------------
  res@tmXBLabels = ref&time(0::tt)

Hopefully that all makes sense.. What all this means is that yes, you
can get your correct labels on there. But each timestep in your array
will cover the same distance along the x-axis, no matter what the
original ref&time value is.

Thus, if your times actually do this:
14:04:13
14:04:30
14:05:30
14:09:12
the spacing along the x-axis between the first two and next two points
will be the same. (This is what the indecipherable error message is
trying to say.) You may or may not want this to be the case. If you
don't, I would suggest coming up with a new time array that is in a
float, double, or integer format. If you need assistance with that let
me know, and I can ask around. (I don't know of an easy way off the top
of my head...)

Hope that helps!
Adam

On 6/1/11 9:29 PM, Adam Phillips wrote:
> Hi Cory,
> If I understand what you've tried so far, you've done this:
> res@tmXBMode = "Automatic"
> that resulted in correct but too few labels...
>
> And you've tried something like this:
> res@tmXBMode = "Explicit"
> res@tmXBValues = ref&time
> res@tmXBLabels = ref&time
> that resulted in a bunch of labels at the far left of the plot and an
> error message...
>
> Have you tried the latter method while subsetting the time arrays:
> res@tmXBMode = "Explicit"
> res@tmXBValues = ref&time(0::96) ; choose the first time thru the last
> res@tmXBLabels = res@tmXBValues ; time and stride by 96
>
> If that doesn't help or if I misunderstood your query let the group know..
> Adam
>
>
>> Hi all,
>> I'm having a problem getting labels on the x-axis of a plot to show up.
>> My data have time along the x-axis and height along the y-axis so I set
>> the coordinates as those arrays of values. When I print the variable
>> I'm trying to plot it appears that my coordinates have been set up
>> correctly as I get the following output:
>> Variable: ref
>> Type: float
>> Total Size: 4816000 bytes
>> 1204000 values
>> Number of Dimensions: 2
>> Dimensions and sizes: [lev | 500] x [time | 2408]
>> Coordinates:
>> lev: [9.836..49092.44]
>> time: [14:04:13..19:39:34]
>> Number Of Attributes: 5
>> valid_time : 20050216
>> missing_value : -500
>> units : dBZ
>> long_name : Reflectivity
>> _FillValue : -500
>>
>> My time is formatted as HH:MM:SS and maybe that is causing a problem.
>> I'm using gsn_csm_contour to plot ref and have tried messing around with
>> tmXBMode to no avail. If I set it as "Explicit" it tries to plot all
>> 2408 tick marks and labels and then gives an error when it reaches 256.
>> When tmXBLabelStride is set it appears to ignore my labels altogether.
>> If I leave it as "Automatic" then it labels the axis nicely, but with
>> values from 0 to 2400 with labels every 400 values. How can I get my
>> times to show up along the bottom where I want them? The height values
>> on the y-axis show up fine with no problems so I must be doing something
>> wrong with the x-axis labels and/or values. Thanks.
>>
>> Cory
>>
>> --
>> ========================================
>> Cory Wolff
>> Associate Scientist
>> National Center for Atmospheric Research
>> 303.497.2845
>> cwolff@ucar.edu
>>
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>
> __________________________________________________
> Adam Phillips
> National Center for Atmospheric Research
> Climate and Global Dynamics Division
> P.O. Box 3000
> Boulder, CO 80307-3000 tel: (303) 497-1726
> http://www.cgd.ucar.edu/cas/asphilli
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-- 
========================================
Cory Wolff
Associate Scientist
National Center for Atmospheric Research
303.497.2845
cwolff@ucar.edu
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Jun 2 14:55:02 2011

This archive was generated by hypermail 2.1.8 : Thu Jun 09 2011 - 14:56:48 MDT