Add a Legend to a Bubble Plot
Add a legend for bubbles to a bubble plot.
BubbleLegend(x, y = NULL, radius, cols, labels = NULL, cols.lbl = "black", width = NULL, xjust = 0, yjust = 1, inset = 0, border = "black", frame = TRUE, adj = c(0.5, 0.5), cex = 1, bg = NULL, asp = NULL, ...)
- the left x-coordinate to be used to position the legend. See 'Details'.
- the top y-coordinate to be used to position the legend. See 'Details'.
- the radii for the bubbles in BubbleLegend.
- the color appearing in the legend.
- a vector of labels to be placed at the right side of the legend.
- the textcolor for the labels of the bubbles.
- the width of the legend.
- how the legend is to be justified relative to the legend x location. A value of 0 means left justified, 0.5 means centered and 1 means right justified.
- the same as xjust for the legend y location.
- inset distance(s) from the margins as a fraction of the plot region when legend is placed by keyword.
- defines the bordor color of each rectangle. Default is none (
- defines the bordor color of the frame around the whole legend. Default is none (
- text alignment, horizontal and vertical.
- character extension for the labels, default 1.0.
- the background color for the bubble legend.
- the aspect ratio width/height. If this is left blank it will be calculated automatically.
- further arguments are passed to the function text.
The labels are placed in the middle of the legend.
The location of the legend may be specified by setting x to a single keyword from the list
"center". This places the legend on the inside of the plot frame at the given location. Partial argument matching is used. The optional inset argument specifies how far the legend is inset from the plot margins. If a single value is given, it is used for both margins; if two values are given, the first is used for x- distance, the second for y-distance. This is the same behaviour as it's implemented in
PlotBubble(x=d.pizza$delivery_min, y=d.pizza$temperature, area=d.pizza$price, xlab="delivery time", ylab="temperature", col=SetAlpha(as.numeric(d.pizza$area)+2, .5), border="darkgrey", na.rm=TRUE, main="Price-Bubbles", panel.first=grid()) BubbleLegend("bottomleft", frame=TRUE, cols=SetAlpha("steelblue",0.5), bg="green", radius = c(1, 2.5, 5), labels=c(1500, 1000, 500), cex=0.8, cols.lbl=c("yellow", "red","blue"))