Learn R Programming

⚠️There's a newer version (0.2.1) of this package.Take me there.

geofacet

This R package provides geofaceting functionality for ggplot2. Geofaceting arranges a sequence of plots of data for different geographical entities into a grid that strives to preserve some of the original geographical orientation of the entities. It's easiest to describe with examples. See below.

Install

install.packages("geofacet")
# or from github:
# devtools::install_github("hafen/geofacet")

Example

See here for the package vignette.

Barchart of state rankings in various categories:

library(ggplot2)

ggplot(state_ranks, aes(variable, rank, fill = variable)) +
  geom_col() +
  coord_flip() +
  facet_geo(~ state) +
  theme_bw()

Unemployment rate time series for each state:

ggplot(state_unemp, aes(year, rate)) +
  geom_line() +
  facet_geo(~ state, grid = "us_state_grid2") +
  scale_x_continuous(labels = function(x) paste0("'", substr(x, 3, 4))) +
  ylab("Unemployment Rate (%)")

GDP per capita in relation to EU index (100) for each country in the European Union:

ggplot(eu_gdp, aes(year, gdp_pc)) +
  geom_line(color = "steelblue") +
  facet_geo(~ name, grid = "eu_grid1", scales = "free_y") +
  scale_x_continuous(labels = function(x) paste0("'", substr(x, 3, 4))) +
  ylab("GDP Per Capita in Relation to EU Index (100)") +
  theme_bw()

Copy Link

Version

Install

install.packages('geofacet')

Monthly Downloads

1,128

Version

0.1.9

License

MIT + file LICENSE

Maintainer

Last Published

March 29th, 2018

Functions in geofacet (0.1.9)

attach_spdf

Attach a SpatialPolygonsDataFrame object to a grid
eu_gdp

eu_gdp
get_ne_data

Get rnaturalearth data
aus_pop

aus_pop
get_grid_names

Get a list of valid grid names
plot.facet_geo

Plot geofaceted ggplot2 object
state_ranks

state_ranks
sa_pop_dens

sa_pop_dens
facet_geo

Arrange a sequence of geographical panels into a grid that preserves some geographical orientation
state_unemp

state_unemp
grid_submit

Submit a grid to be included in the package
print.facet_geo

Print geofaceted ggplot2 object
geofacet

geofacet
london_afford

london_afford
nhs_scot_dental

nhs_scot_dental
grids

Geo Grids
grid_preview

Plot a preview of a grid
grid_auto

Generate a grid automatically from a country/continent name or a SpatialPolygonsDataFrame
grid_design

Interactively design a grid
+.gg

Add method for gg / facet_geo
india_pop

india_pop
auto_states

auto_states
eu_imm

eu_imm
election

election