https://github.com/hafen/geofacet
R package for geographical faceting with ggplot2
https://github.com/hafen/geofacet
geography ggplot2 r visualization
Last synced: 6 months ago
JSON representation
R package for geographical faceting with ggplot2
- Host: GitHub
- URL: https://github.com/hafen/geofacet
- Owner: hafen
- License: other
- Created: 2017-05-20T19:35:05.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-08-24T00:44:40.000Z (about 1 year ago)
- Last Synced: 2025-04-13T00:42:29.235Z (6 months ago)
- Topics: geography, ggplot2, r, visualization
- Language: R
- Homepage: https://hafen.github.io/geofacet/
- Size: 9.18 MB
- Stars: 338
- Watchers: 14
- Forks: 45
- Open Issues: 136
-
Metadata Files:
- Readme: README.md
- Changelog: NEWS.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/hafen/geofacet/actions/workflows/R-CMD-check.yaml)
[](https://app.codecov.io/gh/hafen/geofacet?branch=master)
[](https://CRAN.R-project.org/package=geofacet)
[](https://CRAN.R-project.org/package=geofacet)# 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
```r
install.packages("geofacet")
# or from github:
# remotes::install_github("hafen/geofacet")
```## Example
See [here](https://hafen.github.io/geofacet/) for the package vignette.
Barchart of state rankings in various categories:
```r
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:
```r
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:
```r
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()
```