Learn R Programming

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:
# remotes::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,032

Version

0.2.4

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Ryan Hafen

Last Published

June 28th, 2025

Functions in geofacet (0.2.4)

india_pop

india_pop
london_afford

london_afford
grid_design

Interactively design a grid
grid_submit

Submit a grid to be included in the package
grid_preview

Plot a preview of a grid
plot.facet_geo

Plot geofaceted ggplot2 object
get_ne_data

Get rnaturalearth data
grid_auto

Generate a grid automatically from a country/continent name or a SpatialPolygonsDataFrame or `sf` polygons
nhs_scot_dental

nhs_scot_dental
grids

Geo Grids
print.facet_geo

Print geofaceted ggplot2 object
sa_pop_dens

sa_pop_dens
state_unemp

state_unemp
state_ranks

state_ranks
aus_pop

aus_pop
facet_geo

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

Perform post-processing on a facet_geo ggplot object
get_grid_names

Get a list of valid grid names
attach_spdf

Attach a SpatialPolygonsDataFrame object to a grid
eu_imm

eu_imm
election

election
auto_states

auto_states
eu_gdp

eu_gdp
geofacet-package

geofacet: 'ggplot2' Faceting Utilities for Geographical Data