barmap: Map barplot

View source: R/plot_special.R

barmapR Documentation

Map barplot

Description

Creates a barplot in the shape of a map region.

Usage

barmap(x, db = "worldHires", region, labels = NULL, cols = NULL)

Arguments

x

a vector of proportions summing to 1 (approximately)

db

data base; see map

region

the region; see map

labels

optional vector of labels for each section

cols

a vector of colors for each section

Examples

op <- par(mar = c(0, 0, 0, 0))
barmap(1, region = 'Germany')

barmap(c(1, 1, 1) / 3, region = 'Germany', cols = c('gold', 'red', 'black'))
 
voteGermany2013 <- read.table(
  header = TRUE, text = "Party Result
                         1 CDU/CSU   49.4
                         2     SPD   30.5
                         3   LINKE   10.2
                         4  GRUENE   10.0"
)
 
with(voteGermany2013, {
  barmap(Result / 100, region = 'Germany',
         labels = sprintf('%s (%s%%)', Party, Result))
})
par(op)


raredd/plotr documentation built on Nov. 19, 2023, 4:09 a.m.