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

either 'auto', 'manual' or 'input'. See Description above.

layer

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

fontsize

in 'auto' mode, size of the text.

fonttype

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

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

col

in 'auto' mode, color of the text.

LabelTable

in 'input' mode, a 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, R colors.

Examples



#Example 1: 'auto' mode
#label ASDs in bold and red
ASDs=load_ASDs()
plot(ASDs)
add_labels(mode='auto',layer='ASDs',fontsize=1,fonttype=2,col='red')
#add MPAs and EEZs and their labels in large, green and vertical text
MPAs=load_MPAs()
EEZs=load_EEZs()
plot(MPAs,add=TRUE,border='green')
plot(EEZs,add=TRUE,border='green')
add_labels(mode='auto',layer=c('EEZs','MPAs'),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)
#plot(SmallBathy)
#ASDs=load_ASDs()
#plot(ASDs,add=TRUE)
#MyLabels=add_labels(mode='manual')


#Example 3: Re-use the label table generated in Example 2
#plot(SmallBathy)
#plot(ASDs,add=TRUE)
#add_labels(mode='input',LabelTable=MyLabels)






[Package CCAMLRGIS version 3.0.7 Index]