Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/arvi1000/rGridMap

R Package for tessellated hexagon grid maps of US states in R + ggplot2
https://github.com/arvi1000/rGridMap

Last synced: about 2 months ago
JSON representation

R Package for tessellated hexagon grid maps of US states in R + ggplot2

Awesome Lists containing this project

README

        

# rGridMap
An R Package for tessellated hexagon grid maps of US states in R + ggplot2

Inspired by the [blog post](http://blog.apps.npr.org/2015/05/11/hex-tile-maps.html) by Danny DeBelius of the NPR visuals team and the general 2015 tweet storm and [Flowing Data covereage](https://flowingdata.com/2015/05/12/the-great-grid-map-debate-of-2015/) of grid maps.

It is easy to use!

### Installation

Use install_github from the devtools package

library(devtools)
install_github('arvi1000/rGridMap')

### A toy example

# a data.frame of states with random categorical value
my_dat <- data.frame(state.abb = c(state.abb, 'DC'), # don't forget DC!
value=sample(LETTERS[1:5], 51, replace=T))

# build grid map plot
my_grid_map <- plotGridMap(my_dat, fill_var = 'value')

# and you can manipulate the resultant object as you would any ggplot object
my_grid_map +
scale_fill_brewer(type='qual') +
labs(title = 'States by Category', fill = 'Category')
![](example/rGridMap_example.png)

### An example with real data
(See the [examples folder](example/senate_debut_example.R) for code)
![](example/senate_debut.png)

### Dark theme example

Here's an example where we set the state text labels and hex outlines to white (using parameters of `plotGridMap()`), make the plot background black (using standard ggplot parameters to `theme()`), and apply a viridis color scale (using `scale_fill_viridis_c()`, from ggplot).

(See the [examples folder](example/dark_theme_example.R) for code)
![](example/dark_theme.png)