addBubbles | 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.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", ...)
events |
EventData to use (required). |
type |
|
z.max |
|
min.size |
|
max.size |
|
symbol.zero |
|
symbol.fg |
|
symbol.bg |
|
legend.pos |
|
legend.breaks |
|
show.actual |
|
legend.type |
|
legend.title |
|
legend.cex |
|
neg.col |
|
... |
|
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
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: 2024-09-25
Tanimura, S., Kuroiwa, C., and Mizota, T. (2006) Proportional symbol mapping in R. Journal of Statistical Software 15(5).
In package PBSmapping:
addPolys
,
EventData
,
RGB2RYB
,
surveyData
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)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.