add_labels {CCAMLRGIS} | R Documentation |
Add labels
Description
Adds labels to plots. Three modes are available:
In 'auto'
mode, labels are placed at the centres of polygon parts of spatial objects
loaded via the load_
functions. Internally used in conjunction with Labels
.
In 'manual'
mode, users may click on their plot to position labels. An editable label table is generated
to allow fine-tuning of labels appearance, and may be saved for external use. To edit the label table,
double-click inside one of its cells, edit the value, then close the table.
In 'input'
mode, a label table that was generated in 'manual'
mode is re-used.
Usage
add_labels(
mode = NULL,
layer = NULL,
fontsize = 1,
fonttype = 1,
angle = 0,
col = "black",
LabelTable = NULL
)
Arguments
mode |
character, either |
layer |
character, in |
fontsize |
numeric, in |
fonttype |
numeric, in |
angle |
numeric, in |
col |
character, in |
LabelTable |
in |
Value
Adds labels to plot. To save a label table generated in 'manual'
mode, use:
MyLabelTable=add_labels(mode='auto')
.
To re-use that label table, use:
add_labels(mode='input',LabelTable=MyLabelTable)
.
See Also
Labels
, load_ASDs
, load_SSRUs
, load_RBs
,
load_SSMUs
, load_MAs
, load_EEZs
,
load_MPAs
, add_Legend
,
R colors.
Examples
#Example 1: 'auto' mode
#label ASDs in bold and red
ASDs=load_ASDs()
plot(st_geometry(ASDs))
add_labels(mode='auto',layer='ASDs',fontsize=1,fonttype=2,col='red')
#add EEZs and their labels in large, green and vertical text
EEZs=load_EEZs()
plot(st_geometry(EEZs),add=TRUE,border='green')
add_labels(mode='auto',layer='EEZs',fontsize=2,col='green',angle=90)
#Example 2: 'manual' mode (you will have to do it yourself)
#Examples 2 and 3 below are commented (remove the # to test)
#library(terra)
#plot(SmallBathy())
#ASDs=load_ASDs()
#plot(st_geometry(ASDs),add=TRUE)
#MyLabels=add_labels(mode='manual')
#Example 3: Re-use the label table generated in Example 2
#plot(SmallBathy())
#plot(st_geometry(ASDs),add=TRUE)
#add_labels(mode='input',LabelTable=MyLabels)