Font size for labels made by legend.jnl are inconsistent
ACManke opened this issue · 1 comments
This thread discusses this issue
https://www.pmel.noaa.gov/maillists/tmap/ferret_users/fu_2019/msg01171.html @ryofurue
The legend.jnl script uses ppl commands to draw colored lines labeled with user-generated labels, in one corner of a plot being drawn. It uses "ppl labs" to define pplus moveable labels, which are enumerated labels at a particular location on the plot page, relative to the plot origin in either /USER units (world coordinate units) or /NOUSER units (plot "inches" relative to the plot origin).
The size of moveable labels should be controllable using the PPL labset command, but as summarized by Ryo here,
- The PLOT command sets up automatic labels (logo, dataset name, regions, etc.).
- The "legend" script overwrites some of those labels (using PPL's label command, which is PPL LABS).
- But the labels retain their sizes set at step (1).
So, there is a bug in the moveable-labels code somewhere, but in the meantime, we can add a little logic to the legend.jnl script: Add an optional argument so the user can specify the label size to be used for the legend labels, with a default sizez of 0.12 plot inches. Then issue the PPL HLABS command to set the label size for each label created.
Proposed updated version of legend.jnl
\cancel mode verify
! Contributed by Hein Zelle, 11-December-2003
! Run test_legend.jnl for an example which calls this script.
! script to add a legend line to a plot
! use this between plot/set_up and ppl plot.
! it may also work before a plot/overlay, but I'm not sure.
! if it doesn't, change it to use immediate mode: remove the "on"
! argument to ppl aline. For skipping lines we'll need to write a more
! advanced script that keeps track of how many times we've been called
! so far.
!
! go legend line# title [location] [size]
!
! where location is one of ul, ur, ll or lr
! default location is ul
! Size for legend text is in plot inches, default 0.12
query/ignore $1%<usage: go legend line# title [location: ul* ur ll lr] [label_size]%
query/ignore $2%<usage: go legend line# title [location: ul* ur ll lr] [label_size]%
query/ignore $3%1|ul>1|ur>2|ll>3|lr>4|<location must be ul, ur, ll or lr%
let legend_labsize = $4%0.12%
IF `legend_labsize le 0` then
say **ERROR legend.jnl Argument 4 size must be positive `legend_labsize,p=4`
exit/prompt
endif
ppl hlabs,$1,`legend_labsize`
if `$3%1|ul>1|ur>2|ll>3|lr>4|% eq 1` then ! left top
ppl aline/nouser $1,0.1,`($PPL$YLEN)-0.2*$1`,0.5,`($PPL$YLEN)-0.2*$1`,on
ppl labs/nouser $1,0.6,`($PPL$YLEN)-0.05-0.2*$1`,-1,"$2"
elif `$3%1|ul>1|ur>2|ll>3|lr>4|% eq 2` then ! right top
ppl aline/nouser $1,`($PPL$XLEN)-0.1`,`($PPL$YLEN)-0.2*$1`,`($PPL$XLEN)-0.5`,`($PPL$YLEN)-0.2*$1`,on
ppl labs/nouser $1,`($PPL$XLEN)-0.6`,`($PPL$YLEN)-0.05-0.2*$1`,1,"$2"
elif `$3%1|ul>1|ur>2|ll>3|lr>4|% eq 3` then ! left bottom
ppl aline/nouser $1,0.1,`0.2*$1`,0.5,`0.2*$1`,on
ppl labs/nouser $1,0.6,`-0.05+0.2*$1`,-1,"$2"
else ! right bottom
ppl aline/nouser $1,`($PPL$XLEN)-0.1`,`0.2*$1`,`($PPL$XLEN)-0.5`,`0.2*$1`,on
ppl labs/nouser $1,`($PPL$XLEN)-0.6`,`-0.05+0.2*$1`,1,"$2"
endif
say label `$1`: "$2"
cancdel variable legend_labsize
set mode /last verify