Skip to content

Instantly share code, notes, and snippets.

View willgearty's full-sized avatar
💻

William Gearty willgearty

💻
View GitHub Profile
@willgearty
willgearty / gggeo_scale.R
Last active May 7, 2019 19:46
Add a geologic time scale to a ggplot
gggeo_scale <- function(gg, fill = NULL, color = "black", alpha = 1, height = .05, size = 5, quat = FALSE, pos = "bottom", abbrv = TRUE, periods = NULL, neg = FALSE) {
#This is a function to add a geologic time scale to a ggplot object.
#gg: the ggplot object
#fill: the fill color of the boxes; default are the colors from the Commission for the Geological Map of the World (CGMW);
# custom fill colors can be provided and will be recycled if necessary
# if a custom dataset is provided with periods without color and without fill, a greyscale will be used
#color: the outline color of the boxes
#alpha: transparency of the fill colors
#height: the proportional height of the plot to use for the scale
#size: the size of the text in the scale