! annotate_examples.jnl
! Description: demo of the ANNOTATE command for adding labels to plots
!
! The command ANNOTATE /USER/NORM/NOUSER/XPOS/YPOS/HALIGN/VALIGN/ANGLE/SIZE
! locates user-defined labels on a plot.
!   /USER and /NOUSER behave as the LABEL command does
!   /NORM locates labels relative to the plot axis, treating them as a unit "square".
!   /VALIGN moves the label up or down relative to the direction of the label
!   /HALIGN is -1, 1, or 0 as always, or larger values to move the label horizontally
!         relative to the direction of the label. Allows us to move, say, one character in
!         or out from the axis corner.

can mode logo

if ($program_name"0|pyferret>1|*>0") THEN
   set text/font=arial
   set text/font=arial/color=blue/italic moveable
endif

! ANNOTATE /USER acts like LABEL/USER, locating labels using user-units such 
! as longitude, latitude
pause

define symbol makemap = go basemap   " "  " "   " "    gray_light

($makemap)
annotate/user/xpos=180/ypos=0/halign=0/valign=0/siz=0.12 "Center of Pacific"
annotate/user/xpos=279.8/ypos=25.8 /halign=-1/valign=0/siz=0.12  "Miami"


! ANNOTATE /NORM locates labels relative to the plot axes, as if they form a unit square 
pause

($makemap)
annotate/norm/xpos=.5/ypos=1.1/halign=0/angle=0/size=0.14 "FLOATING TITLE"

annotate/norm/xpos=.5/ypos=-.2/halign=0/angle=0/size=0.14 "SUBMERGED TITLE"

annotate/norm/xpos=.5/ypos=.5/halign=0/valign=0/angle=0/size=0.14 "DEAD CENTER"
pause

annotate/norm/xpos=0/ypos=1/halign=-1/angle=0/size=0.14 "LEFT/TOP"

annotate/norm/xpos=.5/ypos=1/halign=0/angle=0/size=0.14 "CTR/TOP"

annotate/norm/xpos=1/ypos=1/halign=1/angle=0/size=0.14 "RIGHT/TOP"

annotate/norm/xpos=1/ypos=.5/halign=0/angle=-90/size=0.14 "RIGHT EDGE"

annotate/norm/xpos=0/ypos=.5/halign=0/angle=90/size=0.14 "LEFT EDGE"

annotate/norm/xpos=.5/ypos=0/halign=0/valign=1/angle=0/size=0.14 "HANGING FROM BOTTOM"
pause

annotate/norm/xpos=0/ypos=0/halign=-2/valign=-2/angle=0/siz=0.1 "BOTTOM LEFT INSET"

annotate/norm/xpos=0/ypos=1/halign=-2/valign=2/angle=0/siz=0.1 "TOP LEFT INSET"

annotate/norm/xpos=1/ypos=0/halign=2/valign=-2/angle=0/siz=0.1 "BOTTOM RIGHT INSET"

annotate/norm/xpos=1/ypos=1/halign=2/valign=2/angle=0/siz=0.1 "TOP RIGHT INSET"
pause

! ANNOTATE /NOUSER locates labels like LABEL/NOUSER, using plot "inch" units relative tothe plot origin.
pause

 ($makemap)
annotate/nouser/xpos=`($ppl$xlen)/2`/ypos=($ppl$ylen)/halign=0/valign=-8/siz=.25 "ANNOTATE/NOUSER labels"

annotate/nouser/xpos=0/ypos=0/halign=-1/angle=0/size=0.15 "At Origin"
annotate/nouser/xpos=0/ypos=0/halign=-3/valign=-4/angle=0/size=0.15 "With/HALIGN=-3/VALIGN=-4"

annotate/nouser/xpos=($ppl$xlen)/ypos=($ppl$ylen)/halign=1/valign=-1/angle=0/siz=0.15 "Right-align at upper right corner"
annotate/nouser/xpos=($ppl$xlen)/ypos=($ppl$ylen)/halign=4/valign=3/angle=0/siz=0.15 "With/HALIGN=3/VALIGN=4"

pause

annotate/nouser/xpos=`($ppl$xlen)/2`/ypos=`($ppl$ylen)/2`/halign=0/valign=0/angle=0/siz=0.15 \
"Arguments locate the first<nl>line of multi-line labels "
pause

! ANNOTATE/NORM with angles.  /HALIGN is used to determine the start of the label relative to the location
pause
($makemap)
annotate/norm/xpos=.5/ypos=.5/halign=-2/valign=0/angle=45/size=0.14 "angle 45, halign=-2"
annotate/norm/xpos=.5/ypos=.5/halign=2/valign=0/angle=45/size=0.14 "angle 45, halign=2"
annotate/norm/xpos=.5/ypos=.5/halign=-2/valign=0/angle=-45/size=0.14 "angle -45, halign=-2"
annotate/norm/xpos=.5/ypos=.5/halign=2/valign=0/angle=-45/size=0.14 "angle -45, halign=2"


