plot_brmap: Facilitated plot of brazilian maps

Description Usage Arguments Value See Also Examples

View source: R/plot_brmap.R

Description

A wrapper in order to facilitate the plot of the maps from this package. The function returns a ggplot object so it can be edited easily.

Usage

1
2
plot_brmap(map, data_to_join = data.frame(), join_by = NULL,
  var = "values", theme = theme_map())

Arguments

map

An object of class 'sf', 'SpatialPolygonsDataFrame' or 'data.frame'

data_to_join

A data frame containing values to plot on the map.

join_by

A character vector of variables to join by.

var

The name of the column that contains the values of the field to be plotted. The default is "value".

theme

The theme that should be used for plotting the map. The default is theme_map.

Value

A ggplot object that contains a basic brazilian map with the described parameters. Since the result is a ggplot object, it can be extended with more geom layers, scales, labels, themes, etc.

See Also

get_brmap, theme

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
## Plotting population estimates (2017) of the South Region
data("pop2017")
map_sul <- get_brmap(geo = "City", geo.filter = list(Region = 4))
mapa1 <- plot_brmap(map_sul,
                    data_to_join = pop2017,
                    join_by = c("City" = "mun"),
                    var = "pop2017")
mapa1

# Output is ggplot object so it can be extended
# with any number of ggplot layers
library(ggplot2)
mapa1 +
  labs(title = "Popula<c3><a7><c3><a3>o Municipal 2017 - Regi<c3><a3>o Sul")


# Only displaying the microregions of the state of Sao Paulo
map_sp_micro <- get_brmap(geo = "MicroRegion",
                          geo.filter = list(State = 35),
                          class = "SpatialPolygonsDataFrame")
plot_brmap(map_sp_micro)

brazilmaps documentation built on May 2, 2019, 3:04 a.m.