Skip to content

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

Notifications You must be signed in to change notification settings

arvi1000/rGridMap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rGridMap

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

Inspired by the blog post by Danny DeBelius of the NPR visuals team and the general 2015 tweet storm and Flowing Data covereage 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')

An example with real data

(See the examples folder for code)

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 for code)

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages