[Thread Prev][Thread Next][Index]

Re: vertical alignment of labels



Ansley requested that I "cc" this to the group, so here it is...

I went ahead and wrote a kludge script (attached) that does labeling with
vertical alignment.  It's just like LABEL, but it has an additional
argument (plus 2 more for plots with reversed axes).  Take a look and let
me know if it can be done better.

In particular, I'm wondering if there's a way around the user having to
specify HLIM and VLIM (as noted in the script), and REVX and REVY. Can
these be diagnosed directly from the plot?  Note that I use ($YAXIS_MAX)
instead of ($PPL$YMAX1), etc., as these seem to be more robust to
different types of plots (PLOT, SHADE).

Cheers,

Andrew

----------------------------------------------------------------------
Andrew Wittenberg          Program in Atmospheric and Oceanic Sciences
andyw@splash.princeton.edu                        Princeton University
----------------------------------------------------------------------

\can mode verify
! Usage: go label2 xpos ypos halign angle size "labtxt" [valign revx revy]
! Description: LABEL with vertical alignment.
!
! Inputs:
!   XPOS,YPOS : world coordinates of label
!   HALIGN    : horizontal alignment (-1=left,0=center,1=right)
!   ANGLE     : angle of label in degrees
!   SIZE      : label height in inches
!   LABTXT    : text of label
!   VALIGN    : vertical alignment (-1=bottom,0=center,1=top)
!   REVX      : x axis direction: 1=normal, -1=reversed
!   REVY      : y axis direction: 1=normal, -1=reversed
!
! NOTE: The axis limits used to compute the vertical alignment
! are diagnosed from symbols which are set by Ferret after it
! creates a plot.  These symbols correspond to the data extrema,
! not the axis extrema, so they may be incorrect if the axes were
! determined automatically from the data.  (This is often the case
! with line plots and scatter plots generated by PLOT or PLOT/VS.)
! To fix this, simply specify HLIM and VLIM qualifiers on your
! plot command before running this script.
!
! EXAMPLES:
! yes? use levitus_climatology
! yes? can view
! yes? shade temp[k=1]
! yes? go label2 50 -80 0 0 .3 "X" 0
! yes? shade temp[y=0]
! yes? go label2 50 4000 0 0 .3 "X" 0 " " -1
! yes? plot/vs/sym=28/hl=-5:5/vl=-10:10 {-1,1},{-1,1}
! yes? go label2 -1 -1 0 -90 .5 "X" 0
! yes? go label2 0 0 0 0 .5 "X" 0
! yes? go label2 1 1 0 45 .5 "X" 0
! yes? plot/ov/vs/line=1/nolab {-1,1,1,-1,-1},{4,4,6,6,4}
! yes? go label2 0 5 0 0 .5 "BOX" 0
! yes? plot/ov/vs/line=1/nolab .5*{-1,1,1,-1,-1},{-2,-2,-8,-8,-2}
! yes? go label2 0 -5 0 90 .5 "BOX" 0
! yes? plot/ov/vs/sym=2/size=2/nolab 3,0
! yes? go label2 3 0 0 45 .5 "TOP" 1
! yes? go label2 3 0 0 45 .5 "BOTTOM" -1
!
! atw 10/30/01

let l2_xscale = $8"1"*($PPL$XLEN)/(($XAXIS_MAX)-($XAXIS_MIN))
let l2_yscale = $9"1"*($PPL$YLEN)/(($YAXIS_MAX)-($YAXIS_MIN))

let l2_deg_to_rad = 0.017453292
let l2_dx = 0 - (1+$7"-1")/2 * $5*cos(($4+90)*l2_deg_to_rad)/l2_xscale
let l2_dy = 0 - (1+$7"-1")/2 * $5*sin(($4+90)*l2_deg_to_rad)/l2_yscale
label `$1 + l2_dx` `$2 + l2_dy` $3 $4 $5 "$6"

can var l2_xscale l2_yscale l2_deg_to_rad l2_dx l2_dy
set mode/last verify



[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement