legend.bubble: Legend for bubble plot

View source: R/legend.bubble.R

legend.bubbleR Documentation

Legend for bubble plot

Description

Draw a legend for a bubble plot (draw.bubble)

Usage

legend.bubble(x, y = NULL, z, maxradius = 1, n = 3, round = 0, bty = "o", mab = 1.2, 
	bg = NULL, inset = 0, pch = 21, pt.bg = NULL, txt.cex = 1, 
	txt.col = NULL, font = NULL, ...)

Arguments

x, y

the x and y co-ordinates to be used to position the legend. x can be a keyword (e.g. "topleft"). See legend.

z

either a single value representing the largest bubble, in which case n determines how many bubbles are displayed; or a vector of z values which will be to be shown as bubbles in the legend.

maxradius

the radius of the largest bubble. this should match maxradius in draw.bubble.

n

integer giving the number of bubbles that should be shown in the legend. Defaults to 3. Only relevant when z is a single value.

round

integer indicating the number of decimal places to be used in the legend.

bty

single character indicating the type of box to be drawn around the legend. The allowed values are "o" (the default) and "n" (no box).

mab

the margin around the bubble. i.e. how much space should there be between the largest bubble and the legend box. relative to the size of the bubble.

bg

background colour of the legend box.

inset

inset distance(s) from the margins as a fraction of the plot region when legend is placed by keyword.

pch

plotting character, i.e., symbol to use. Defaults to 21.

pt.bg

background (fill) color for the open plot symbols given by pch=21:25.

txt.cex

character expansion for the legend text.

txt.col

colour of the legend text.

font

An integer which specifies which font to use for text. See graphical parameters

...

any other arguments to be passed to points.

Author(s)

Hans Gerritsen

Examples

data(landings)
data(coast)
xlim <- c(-12,-5)
ylim <- c(50,56)
agg <- aggregate(list(z=landings$LiveWeight),list(x=landings$Lon,y=landings$Lat),sum)
basemap(xlim, ylim, main = "Gadoid landings")
draw.shape(coast, col="cornsilk")
draw.bubble(agg$x, agg$y, agg$z, maxradius=0.5, pch=21, bg="#00FF0050")
legend.bubble("topright", z=round(max(agg$z)/1000,0), maxradius=0.5, inset=0.02, bg="lightblue",
 txt.cex=0.8, pch=21, pt.bg="#00FF0050")

mapplots documentation built on Aug. 25, 2023, 5:15 p.m.