Learn R Programming

cartography (version 1.3.0)

legendChoro: Legend for Choropleth Maps

Description

Plot legend for choropleth maps.

Usage

legendChoro(pos = "topleft", title.txt = "Title of the legend", title.cex = 0.8, values.cex = 0.6, breaks, col, cex = 1, values.rnd = 2, nodata = TRUE, nodata.txt = "No data", nodata.col = "white", frame = FALSE, symbol = "box")

Arguments

pos
position of the legend, one of "topleft", "top", "topright", "left", "right", "bottomleft", "bottom", "bottomright".
title.txt
title of the legend.
title.cex
size of the legend title.
values.cex
size of the values in the legend.
breaks
break points in sorted order to indicate the intervals for assigning the colors. Note that if there are nlevel colors (classes) there should be (nlevel+1) breakpoints.
col
a vector of colors.
cex
size of the legend. 2 means two times bigger.
values.rnd
number of decimal places of the values in the legend.
nodata
if TRUE a "no data" box or line is plotted.
nodata.txt
label for "no data" values.
nodata.col
color of "no data" values.
frame
whether to add a frame to the legend (TRUE) or not (FALSE).
symbol
type of symbol in the legend 'line' or 'box'

Examples

Run this code
data("nuts2006")
plot(nuts0.spdf, col = "grey")
box()
legendChoro(pos = "bottomleft", title.txt = "Title of the legend", title.cex = 0.8,
            values.cex = 0.6, breaks = c(1,2,3,4,10.27,15.2),
            col = carto.pal(pal1 = "orange.pal",n1 = 5), values.rnd =2,
            nodata = TRUE, nodata.txt = "No data available", frame = TRUE, symbol="box")
legendChoro(pos = "bottomright", title.txt = "Title of the legend", title.cex = 0.8,
            values.cex = 0.6, breaks = c(1,2,5,7,10,15.27),
            col = carto.pal(pal1 = "wine.pal",n1 = 5), values.rnd = 0,
            nodata = TRUE, nodata.txt = "NA",nodata.col = "black",
            frame = TRUE, symbol="line")

Run the code above in your browser using DataLab