PBSmapping (version 2.72.1)

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.6), symbol.bg=rgb(0,0,0,0.3),
   legend.pos="bottomleft", legend.breaks=NULL,
   show.actual=FALSE, legend.type=c("nested","horiz","vert"),
   legend.title="Abundance", legend.cex=0.8, ...)

Arguments

events

EventData to use (required).

type

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

z.max

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

min.size

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

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

symbol to represent z-values equal to 0.

symbol.fg

bubble outline (border) colour.

symbol.bg

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

position for the legend.

legend.breaks

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

display format for legend.

legend.title

title for legend.

legend.cex

size of legend text.

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

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

addPolys, surveyData

Examples

Run this code
# NOT RUN {
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))
  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))
  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