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 'auto', 'manual' or 'input'. See Description above.

layer

character, in 'auto' mode, single or vector of characters, may only be one, some or all of: c("ASDs","SSRUs","RBs","SSMUs","MAs","MPAs","EEZs").

fontsize

numeric, in 'auto' mode, size of the text.

fonttype

numeric, in 'auto' mode, type of the text (1 to 4), where 1 corresponds to plain text, 2 to bold face, 3 to italic and 4 to bold italic.

angle

numeric, in 'auto' mode, rotation of the text in degrees.

col

character, in 'auto' mode, color of the text.

LabelTable

in 'input' mode, name of the label table that was generated in 'manual' mode.

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)






[Package CCAMLRGIS version 4.1.1 Index]