Proportional Symbols Layer

Share:

Description

Plot a proportional symbols layer.

Usage

1
2
3
4
5
6
propSymbolsLayer(spdf, df, spdfid = NULL, dfid = NULL, var, inches = 0.3,
  fixmax = NULL, breakval = NULL, symbols = "circle", col = "#E84923",
  col2 = "#7DC437", border = "black", lwd = 1,
  legend.pos = "bottomleft", legend.title.txt = var,
  legend.title.cex = 0.8, legend.values.cex = 0.6, legend.values.rnd = 0,
  legend.style = "c", legend.frame = FALSE, add = TRUE, k = NULL)

Arguments

spdf

a SpatialPointsDataFrame or a SpatialPolygonsDataFrame; if spdf is a SpatialPolygonsDataFrame symbols are plotted on centroids.

df

a data frame that contains the values to plot. If df is missing spdf@data is used instead.

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.

inches

size of the biggest symbol (radius for circles, width for squares, height for bars) in inches.

fixmax

value of the biggest symbol (see Details).

breakval

breaking value (see Details).

symbols

type of symbols, one of "circle", "square" or "bar".

col

color of symbols.

col2

second color of symbols (see Details).

border

color of symbols borders.

lwd

width of symbols borders.

legend.pos

position of the legend, one of "topleft", "top", "topright", "left", "right", "bottomleft", "bottom", "bottomright". If legend.pos is "n" then the legend is not plotted.

legend.title.txt

title of the legend.

legend.title.cex

size of the legend title.

legend.values.cex

size of the values in the legend.

legend.values.rnd

number of decimal places of the values displayed in the legend.

legend.style

either "c" or "e". The legend has two display styles, "c" stands for compact and "e" for extended.

legend.frame

boolean; 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.).

Details

The breakval parameter allows to plot symbols of two colors: the first color (col) for values superior or equal to breakval, second color (col2) for values inferior to breakval.

Two maps with the same inches and fixmax parameters will be comparable.

See Also

legendBarsSymbols, legendCirclesSymbols, legendSquaresSymbols, propSymbolsChoroLayer, propSymbolsTypoLayer

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
data("nuts2006")
## Example 1
# Layout plot
layoutLayer(title = "Countries Population in Europe",
            sources = "Eurostat, 2008",
            scale = NULL,
            frame = TRUE,
            col = "black",
            coltitle = "white",
            bg = "#D9F5FF",
            south = TRUE,
            extent = nuts0.spdf)
# Countries plot
plot(nuts0.spdf, col = "grey60",border = "grey20", add=TRUE)
# Population plot on proportional symbols
propSymbolsLayer(spdf = nuts0.spdf, df = nuts0.df,
                 var = "pop2008", 
                 symbols = "square", col =  "#920000",
                 legend.pos = "right",
                 legend.title.txt = "Total\npopulation (2008)",
                 legend.style = "c")

## Example 2
# Countries plot
plot(nuts0.spdf, col = "grey60",border = "grey20")
# Population plot on proportional symbols
propSymbolsLayer(spdf = nuts0.spdf, df = nuts0.df,
                 var = "gdppps2008",
                 symbols = "bar", col =  "#B00EF0",
                 legend.pos = "right",
                 legend.title.txt = "GDP\nin Millions PPS (2008)",
                 legend.style = "e")

## Example 3
oldpar <- par(mfrow = c(1,2), mar = c(0,0,0,0))
# Countries plot
plot(nuts0.spdf, col = "grey60",border = "grey20", add=FALSE)
# Population plot on proportional symbols
propSymbolsLayer(spdf = nuts0.spdf, df = nuts0.df,
                 var = "birth_2008", 
                 fixmax = max(nuts0.df$birth_2008),
                 inches = 0.2,
                 symbols = "circle", col =  "orange",
                 legend.pos = "right",
                 legend.title.txt = "nb of births",
                 legend.style = "e")
plot(nuts0.spdf, col = "grey60",border = "grey20", add=FALSE)
# Population plot on proportional symbols
propSymbolsLayer(spdf = nuts0.spdf, df = nuts0.df,
                 var = "death_2008",
                 symbols = "circle", col =  "pink",
                 fixmax = max(nuts0.df$birth_2008),
                 inches = 0.2,
                 legend.pos = "right",
                 legend.style = "e",
                 legend.title.txt = "nb of deaths")
par(oldpar)

## Example 4
nuts0.df$balance <- nuts0.df$birth_2008-nuts0.df$death_2008
plot(nuts0.spdf, col = "grey60",border = "grey20", add=FALSE)
# Population plot on proportional symbols
propSymbolsLayer(spdf = nuts0.spdf, df = nuts0.df, inches = 0.3,
                 var = "balance",
                 symbols = "circle",
                 col = "orange", col2 = "green", breakval=0,
                 legend.pos = "right",
                 legend.style = "c",
                 legend.title.txt = "Natural Balance\n(2008)")

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.