Re: Help with cross-section Y-axis labels

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Tue Feb 14 2012 - 10:28:19 MST

Hi Chris,
       opts_xy@tmYLValues =
fspan(0,zspan,nz) ; Create tick marks
       opts_xy@tmYLLabels =
sprintf("%.1f",fspan(zmin,zmax,nz)) ; Create labels

I would recommend printing the following to see the values/labels you
are setting:
print(fspan(0,zspan,nz)+" "+sprintf("%.1f",fspan(zmin,zmax,nz)))

(Note: The print out should match the Y-axis labels you are seeing in
your plot.)

I would recommend you use ispan instead of fspan if you want labels to
be every 2km. You can do this with fspan as well,
but as you are coding generically (i.e. you are not hard-wiring things
in) it might be best to use ispan. For example this:

opts_xy@tmYLValues = ispan(0,zspan,2)
opts_xy@tmYLLabels = opts_xy@tmYLValues ; this is assuming that the
value/label are the same

Should produce labels at every 2km, labeled as such..
Hope that helps. If not, let ncl-talk know..
Adam

On 02/14/2012 08:46 AM, Chris Klich wrote:
> Hi all, I am currently plotting a cross-section of vertical velocity
> from a WRF output file. However, it seems no matter what I try to do
> the Y-axis labels are odd numbers. For example, in my current script,
> they are in increments of about 2.2km, when in the end I would like
> them every 2 or 3 kilometers. I am fairly new at making cross-section
> plots in NCL, and I have used the sample scripts to help build my
> current code (which is not done formatting). However, I cannot seem
> to figure out how to make the labels "nicer" numbers.
>
> Any help will be appreciated! I've attached the code I'm using, as
> well as pasted below the section of the code that makes the height labels.
>
>
>
> if ( FirstTime ) then ; get height
> info for labels
> zmin = 0.
> zmax = max(z)/1000.
> nz = floattoint(zmax/2 + 1)
> FirstTime = False
> end if
>
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> ; Use the built in latlon to ij function to convert the
> specified ;
> ; latitudes and longitudes to the closest i/x and j/y points in
> the domain ;
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> loc_xy = wrf_user_latlon_to_ij(a,lats,lons)
> ys = loc_xy(0,0) ; Starting y (j)
> location
> ye = loc_xy(1,0) ; Ending y (j)
> location
> xs = loc_xy(0,1) ; Starting x (i)
> location
> xe = loc_xy(1,1) ; Ending x (i)
> location
>
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> ; Specify the start and end points of the cross section after
> creating a ;
> ; plane to store these start and end locations ;
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
>
> plane = new(4,float) ; Create a float plane
> with 4 dimension sizes
> plane = (/ xs,ys , xe,ye /) ; Approx. start
> x,y and end x,y point
>
>
> opts = True ; Set options for the
> wrf_user_intrp3d below to True
> w_plane = wrf_user_intrp2d(w,plane,0.,opts) ; Use the
> wrf_user_intrp2d to create a vertical cross section plane of W with
> interpolated heights
> dim = dimsizes(w_plane) ; Find the data
> span - for use in labels
> zspan = dim(0)
>
>
> opts_xy = res
> opts_xy@tiYAxisString = "Height (km)"
> opts_xy@AspectRatio = 0.75
> opts_xy@cnMissingValPerimOn = True
> opts_xy@cnMissingValFillColor = 0
> opts_xy@cnMissingValFillPattern = 11
> opts_xy@tmYLMode = "Explicit"
> opts_xy@tmYLValues =
> fspan(0,zspan,nz) ; Create tick marks
> opts_xy@tmYLLabels =
> sprintf("%.1f",fspan(zmin,zmax,nz)) ; Create labels
> opts_xy@tiXAxisFontHeightF = 0.020
> opts_xy@tiYAxisFontHeightF = 0.020
> opts_xy@tmXBMajorLengthF = 0.02
> opts_xy@tmYLMajorLengthF = 0.02
> opts_xy@tmYLLabelFontHeightF = 0.015
>
>
> Thank you,
> Chris Klich
>
> --
> Christopher Klich
> Graduate Student
> Florida State University
> (908) 208-9743
>
>
>
> _______________________________________________
> 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 Tue Feb 14 10:28:28 2012

This archive was generated by hypermail 2.1.8 : Fri Feb 17 2012 - 08:50:10 MST