Learn R Programming

cartography (version 1.3.0)

propSymbolsChoroLayer: Proportional and Choropleth Symbols Layer

Description

Plot a proportional symbols layer with color based on a quantitative data discretization.

Usage

propSymbolsChoroLayer(spdf, df, spdfid = NULL, dfid = NULL, var, inches = 0.3, fixmax = NULL, symbols = "circle", border = "grey20", lwd = 1, var2, breaks = NULL, method = "quantile", nclass = NULL, col = NULL, legend.title.cex = 0.8, legend.values.cex = 0.6, legend.var.pos = "right", legend.var.title.txt = var, legend.var.values.rnd = 0, legend.var.style = "c", legend.var.frame = FALSE, legend.var2.pos = "topright", legend.var2.title.txt = var2, legend.var2.values.rnd = 2, legend.var2.nodata = "no data", legend.var2.frame = FALSE, add = TRUE, k = NULL)

Arguments

spdf
SpatialPointsDataFrame or SpatialPolygonsDataFrame; if spdf is a SpatialPolygonsDataFrame symbols are plotted on centroids.
df
a data frame that contains the values to plot.
spdfid
identifier field in spdf, default to the first column of the spdf data frame. (optional)
dfid
identifier field in df, default to the first column of df. (optional)
var
name of the numeric field in df to plot the symbols sizes.
inches
size of the biggest symbol (radius for circles, width for squares, height for bars) in inches.
fixmax
value of the biggest symbol (see propSymbolsLayer Details).
symbols
type of symbols, one of "circle", "square" or "bar".
border
color of symbols borders.
lwd
width of symbols borders.
var2
name of the numeric field in df to plot the colors.
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 (see choroLayer Details).
method
a discretization method; one of "sd", "equal", "quantile", "jenks", "q6" or "geom" (see choroLayer Details).
nclass
a targeted number of classes. If null, the number of class is automatically defined (see choroLayer Details).
col
a vector of colors. Note that if breaks is specified there must be one less colors specified than the number of break.
legend.title.cex
size of the legend title.
legend.values.cex
size of the values in the legend.
legend.var.pos
position of the legend, one of "topleft", "top", "topright", "left", "right", "bottomleft", "bottom", "bottomright". If legend.var.pos is "n" then the legend is not plotted.
legend.var.title.txt
title of the legend (proportional symbols).
legend.var.values.rnd
number of decimal places of the values in the legend.
legend.var.style
either "c" or "e". The legend has two display styles.
legend.var.frame
whether to add a frame to the legend (TRUE) or not (FALSE).
legend.var2.pos
position of the legend, one of "topleft", "top", "topright", "left", "right", "bottomleft", "bottom", "bottomright". If legend.var2.pos is "n" then the legend is not plotted.
legend.var2.title.txt
title of the legend (colors).
legend.var2.values.rnd
number of decimal places of the values in the legend.
legend.var2.nodata
text for "no data" values
legend.var2.frame
whether to add a frame to the legend (TRUE) or not (FALSE).
add
whether to add the layer to an existing plot (TRUE) or not (FALSE).
k
share of the map occupied by the biggest symbol (this argument is deprecated; please use inches instead.).

See Also

legendBarsSymbols, legendChoro, legendCirclesSymbols, legendSquaresSymbols, choroLayer, propSymbolsLayer

Examples

Run this code
data("nuts2006")
## Example 1
# Growth rate
nuts0.df$cagr <- (((nuts0.df$pop2008 / nuts0.df$pop1999)^(1/9)) - 1) * 100
# Countries plot
plot(nuts0.spdf, col = "grey60",border = "grey20", add=FALSE)
# Plot the symbols
propSymbolsChoroLayer(spdf = nuts0.spdf, df = nuts0.df,symbols = "circle", 
                      var = "pop2008", var2 = "cagr")

## Example 2
# Growth rate at nuts2 level
nuts2.df$cagr <- (((nuts2.df$pop2008 / nuts2.df$pop1999)^(1/9)) - 1) * 100

# First layout
layoutLayer(title="Demographic trends, 1999-2008",
            scale = NULL,col = NA, coltitle = "black",
            sources = "", author = "",
            frame = FALSE, bg = "#A6CAE0",
            south = TRUE, extent = nuts0.spdf)
plot(world.spdf, col  = "#E3DEBF", border=NA, add=TRUE)
plot(nuts2.spdf, col = "grey60",border = "white", lwd=0.4, add=TRUE)

# Add some NA values
nuts2.df[1:10,"pop2008"] <- NA
nuts2.df[100:110,"cagr"] <- NA

# Plot symbols
propSymbolsChoroLayer(spdf = nuts2.spdf, df = nuts2.df, 
                      var = "pop2008", var2 = "cagr", 
                      inches = 0.1,
                      col = carto.pal(pal1 = "blue.pal", n1 = 2, 
                                      pal2 = "red.pal", n2 = 4), 
                      breaks = c(-2.43,-1,0,0.5,1,2,3.1),
                      border = "grey50", lwd = 1,
                      legend.var.pos = "topright", legend.var2.pos = "right",
                      legend.var2.title.txt = "Compound annual\ngrowth rate",
                      legend.var.title.txt = "Total Population",
                      legend.var.style = "e")
# Second layout
layoutLayer(title = "", author = "Eurostat, 2011", 
            sources = "", frame ="", col = NA)

Run the code above in your browser using DataLab