ColorLegend | R Documentation |
ColorLegend draws a color legend according to given color mapping parameters.
ColorLegend(
pos,
parameters,
ticks = NULL,
labels = NULL,
resolution = 100,
log = FALSE,
xpd = FALSE,
size = c(40, 3),
margin = 5,
horiz = FALSE,
tick.pos = 1,
tick.size = 1.5,
offset = 0.3,
lwd = 1,
border = TRUE,
...
)
pos |
the legend location which can be specified using either a single keyword in
|
parameters |
a ColorParameters object defined with DefineColorMap. |
ticks |
values of the tick marks for graduation of the color scale
(default = |
labels |
text labels shown next to the tick marks
(default = |
resolution |
the resolution of the color scale or number of elementary units composing the
represented color gradients (default = |
log |
logical. If |
xpd |
logical. If FALSE, the legend position is relative to the plot region (default). If TRUE, the legend position is relative to the entire device region. This second option works fine for separated plots but not for multipanel layouts (see layout). |
size |
the size of the color legend given as a list or a vector in the form
|
margin |
numeric vector controlling the spacing between the legend and the borders
of the plot area and expressed in percentage of its dimensions
(default = |
horiz |
logical controlling the legend layout.
If |
tick.pos |
relative location of graduations, which is indicated by a value of |
tick.size |
length of the tick marks, expressed in percentage of the dimensions of the
plot area (default = |
offset |
spacing between tick marks and tick labels. |
lwd |
line width for tick marks and color scale borders. |
border |
logical activating the drawing of black borders around the color scale
(default = |
... |
optional parameters forwarded to the text function. |
MakeColors, DefineColorMap
# Radial color gradient with two normally distributed random variables
x <- rnorm(2000)
y <- rnorm(2000)
z <- 10^sqrt(x^2 + y^2)
col.par <- DefineColorMap(name = "bantignies")
clrs <- MakeColors(z, parameters = col.par)
plot(x, y, xlim = c(-4.5, 4.5), ylim = c(-5, 4), pch = 20, col = clrs)
ColorLegend(
"bottom", parameters = col.par, log = TRUE, size = c(70, 3), horiz = TRUE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.