colmapLegend | R Documentation |
Draws a legend for a color gradient map created by <code>colmap()</code>.
colmapLegend(
cm,
label,
corner = "topleft",
size = c(0.3, 0.15),
res = 20,
marginSize = 0.2
)
cm |
the colmap object created by colmap() |
label |
the label for the legend |
corner |
a plot corner described as "top" "topleft","bottomright", etc. in which the legend will be drawn. Defaults to "topleft" |
size |
a vector of relative width and height of the legend relative to size of the plotting area. Defaults to c(0.3,0.15) |
res |
resolution of the gradient |
marginSize |
size of the legend margin relative to its width. Default 0.2. |
#create colmap object
cm <- colmap(c(0,1,2),c("royalblue3","yellow","firebrick3"),naCol="gray")
#create some fake data
data <- data.frame(x=rnorm(1000,2,4), y=rnorm(1000,1,5), z=cm(rnorm(1000,1,1)))
#plot the data
with(data, plot(x,y, col=z))
#draw the legend
colmapLegend(cm,"z",corner="topright")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.