addBubbles {PBSmapping} | R Documentation |
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.
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, ...)
events |
EventData to use (required). |
type |
scaling option for bubbles where |
z.max |
maximum value for z (default = |
min.size |
minimum size (inches) for a bubble representing
|
max.size |
maximum size (inches) for a bubble representing
|
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 |
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 |
legend.type |
display format for legend. |
legend.title |
title for legend. |
legend.cex |
size of legend text. |
... |
additional arguments for |
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.
Denis Chabot, Research Scientist
Maurice-Lamontagne Institute, Fisheries & Oceans Canada (DFO), Mont-Joli QC
Last modified Rd: 2013-04-10
Tanimura, S., Kuroiwa, C., and Mizota, T. (2006) Proportional symbol mapping in R. Journal of Statistical Software 15(5).
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) })