PBSmapping (version 2.73.4)

addBubbles: Add Bubbles to Maps

Description

Add bubbles proportional to some EventData's Z column (e.g., catch or effort) to an existing plot, where each unique EID describes a bubble.

Usage

addBubbles(events, type=c("perceptual","surface","volume"),
   z.max=NULL, min.size=0, max.size=0.8, symbol.zero="+",
   symbol.fg=rgb(0,0,0,0.60), symbol.bg=rgb(0,0,0,0.30),
   legend.pos="bottomleft", legend.breaks=NULL,
   show.actual=FALSE, legend.type=c("nested","horiz","vert"),
   legend.title="Abundance", legend.cex=.8, neg.col="RYB", ...)

Arguments

events

EventData to use (required).

type

character -- scaling option for bubbles where "perceptual" emphasizes large z-values, "volume" emphasizes small z-values, and "surface" lies in between.

z.max

numeric -- maximum value for z (default = max(events$Z)); determines the largest bubble; keeps the same legend for different maps.

min.size

numeric -- minimum size (inches) for a bubble representing min(events$Z). The legend may not actually include a bubble of this size because the calculated legend.breaks does not include the min(events$Z).

max.size

numeric -- maximum size (inches) for a bubble representing z.max. A legend bubble may exceed this size when show.actual is FALSE (on account of using pretty(...)).

symbol.zero

character -- symbol to represent z-values equal to 0.

symbol.fg

character -- bubble outline (border) colour.

symbol.bg

character -- bubble interior (fill) colour. If a vector, the first element represents min(legend.breaks) and the last element represents max(legend.breaks); colours are interpolated for values of events$Z between those boundaries. For values outside of those boundaries, interiors remain unfilled.

legend.pos

character|numeric -- position for the legend.

legend.breaks

numeric -- break values for categorizing the z-values. The automatic method should work if zeroes are present; otherwise, you can specify your own break values for the legend. If a single number, specifies the number of breaks; if a vector, specifies the breaks.

show.actual

logical -- if FALSE, legend values are obtained using pretty(...), and consequently, the largest bubble may be larger than z.max; if TRUE, the largest bubble in the legend will correspond to z.max.

legend.type

character -- display format for legend.

legend.title

character -- title for legend.

legend.cex

numeric -- size of legend text.

neg.col

character -- bubble colour for any potential negative values.

...

dots -- additional arguments for points function that plots zero-value symbols.

Author

Denis Chabot, Research Scientist
Maurice-Lamontagne Institute, Fisheries & Oceans Canada (DFO), Mont-Joli QC

Maintainer: Rowan Haigh, Program Head -- Offshore Rockfish
Pacific Biological Station (PBS), Fisheries & Oceans Canada (DFO), Nanaimo BC
locus opus: Offsite, Vancouver BC
Last modified Rd: 2023-11-02

Details

Modified from (and for the legend, strongly inspired by) Tanimura et al. (2006) by Denis Chabot to work with PBSmapping.

Furthermore, Chabot's modifications make it possible to draw several maps with bubbles that all have the same scale (instead of each bubble plot having a scale that depends on the maximum z-value for that plot). This is done by making z.max equal to the largest z-value from all maps that will be plotted.

The user can also add a legend in one of four corners (see legend) or at a specific c(X,Y) position. If legend.pos is NULL, no legend is drawn.

References

Tanimura, S., Kuroiwa, C., and Mizota, T. (2006) Proportional symbol mapping in R. Journal of Statistical Software 15(5).

See Also

In package PBSmapping:
addPolys, EventData, RGB2RYB, surveyData

Examples

Run this code
local(envir=.PBSmapEnv,expr={
  oldpar = par(no.readonly=TRUE)
  #--- common code for both examples below
  data(nepacLL,surveyData,envir=.PBSmapEnv)
  surveyData$Z <- surveyData$catch

  #--- plot a version that only varies the size
  plotMap(nepacLL, xlim=c(-131.8,-127.2), ylim=c(50.5,52.7),
    col="gainsboro",plt=c(.08,.99,.08,.99), cex.axis=1.2, cex.lab=1.5)
  addBubbles(surveyData, symbol.bg=rgb(.9,.5,0,.6),
    legend.type="nested", symbol.zero="+", col="grey")

  #--- plot a version that uses different symbol colours
  plotMap(nepacLL, xlim=c(-131.8,-127.2), ylim=c(50.5,52.7),
  col="gainsboro",plt=c(.08,.99,.08,.99), cex.axis=1.2, cex.lab=1.5)
  subset <- surveyData[surveyData$Z <= 1000, ]
  addBubbles(subset, symbol.bg=c("red", "yellow", "green"),
    legend.type="horiz", legend.breaks=pretty(range(subset$Z), n=11),
    symbol.zero=FALSE, col="grey", min.size=0.1, max.size=0.4)
  par(oldpar)
})

Run the code above in your browser using DataLab