add_PieLegend {CCAMLRGIS}R Documentation

Add a legend to Pies

Description

Adds a legend to pies created using create_Pies.

Usage

add_PieLegend(
  Pies = NULL,
  bb = NULL,
  PosX = 0,
  PosY = 0,
  Size = 25,
  lwd = 1,
  Boxexp = c(0.2, 0.2, 0.12, 0.3),
  Boxbd = "white",
  Boxlwd = 1,
  Labexp = 0.3,
  fontsize = 1,
  LegSp = 0.5,
  Horiz = TRUE,
  PieTitle = "Pie chart",
  SizeTitle = "Size chart",
  PieTitleVadj = 0.5,
  SizeTitleVadj = 0.3,
  nSizes = 3,
  SizeClasses = NULL
)

Arguments

Pies

Spatial object created using create_Pies.

bb

Spatial object, sf bounding box created with st_bbox(). If provided, the legend will be centered in that bb. Otherwise it is centered on the min(Latitudes) and median(Longitudes) of coordinates found in the input Pies.

PosX

numeric, horizontal adjustment of legend.

PosY

numeric, vertical adjustment of legend.

Size

numeric, controls the size of pies.

lwd

numeric, line thickness of pies.

Boxexp

numeric, vector of length 4 controls the expansion of the legend box, given as c(xmin,xmax,ymin,ymax).

Boxbd

character, color of the background of the legend box.

Boxlwd

numeric, line thickness of the legend box. Set to zero if no box is desired.

Labexp

numeric, controls the distance of the pie labels to the center of the pie.

fontsize

numeric, size of the legend font.

LegSp

numeric, spacing between the pie and the size chart (only used if SizeVar was specified in create_Pies).

Horiz

logical. Set to FALSE for vertical layout (only used if SizeVar was specified in create_Pies).

PieTitle

character, title of the pie chart.

SizeTitle

character, title of the size chart (only used if SizeVar was specified in create_Pies).

PieTitleVadj

numeric, vertical adjustment of the title of the pie chart.

SizeTitleVadj

numeric, vertical adjustment of the title of the size chart (only used if SizeVar was specified in create_Pies).

nSizes

integer, number of size classes to display in the size chart. Minimum and maximum sizes are displayed by default. (only used if SizeVar was specified in create_Pies).

SizeClasses

numeric, vector (e.g. c(1,10,100)) of size classes to display in the size chart (only used if SizeVar was specified in create_Pies). If set, overrides nSizes.

Value

Adds a legend to a pre-existing pie plot.

See Also

create_Pies, PieData, PieData2.

Examples


# For more examples, see:
# https://github.com/ccamlr/CCAMLRGIS#23-create-pies

#Pies of constant size, all classes displayed:
#Create pies
MyPies=create_Pies(Input=PieData,
                   NamesIn=c("Lat","Lon","Sp","N"),
                   Size=50
                   )
#Plot Pies
plot(st_geometry(MyPies),col=MyPies$col)
#Add Pies legend
add_PieLegend(Pies=MyPies,PosX=-0.1,PosY=-1,Boxexp=c(0.5,0.45,0.12,0.45),
             PieTitle="Species")




[Package CCAMLRGIS version 4.1.1 Index]