Skip to content

japhir/GeologicTimeScale

Repository files navigation

Make a nice Geologic Time Scale

In this repository I create a nice PDF on A3 size to print the Geologic Time Scale on a linear scale, so that it doesn’t seem like the recent time periods took the same amount of time as the Precambrian.

I had to copy over all the colours and age ranges, because the official tools only provide a PDF.

If you want to use this figure for your own plots you can either:

  1. load in the GTS_widths.csv file and plot it yourself
    library(readr)
    GTS <- read_csv("https://github.com/japhir/GeologicTimeScale/raw/master/GTS_widths.csv")
    # create plot yourself
        
  2. load in the gts_plot.rds file and tweak the plot itself.
    library(ggplot2)
    library(readr)
    gts <- read_rds("https://github.com/japhir/GeologicTimeScale/raw/master/out/gts_plot.rds")
        

I prefer to read in the data, filter out what I want (e.g., only Epochs), then make the plot full-sized and add it to the data with patchwork.

NOTE: it’s probably much better to use a full-fledged package to add the Geologic Time Scale to your plots, e.g. using the deeptime package!

full workflow

load libraries

library(dplyr)
library(ggplot2)
library(readr)

Read in my weird data frame

GTS <- read_csv("https://github.com/japhir/GeologicTimeScale/raw/master/GTS_widths.csv")

Create plot of “data”

dataplot <- iris |>
  # create fake ages
  mutate(age = rep(seq(0, 44, length.out = 50), 3)) |>
  ggplot(aes(x = age, y = Petal.Length, colour = Species)) +
  geom_point() +
  geom_line()
dataplot

imgs/iris.png

Now create the desired subset of the GTS plot

gtsplot <- GTS |>
  # subset it to only show Periods
  filter(type == "Period") |>
  # filter to our time range
  filter(top < 55) |>
  # rectangles for each period
  ggplot() +
  geom_rect(aes(ymin = start, ymax = end, xmin = top, xmax = bot, fill = col),
            show.legend = FALSE, col = "black") +
  # make sure that the fill colour is given by our hex colours
  scale_fill_identity() +
  # add period names
  geom_text(aes(x = meanage, y = meanwidth, label = name, size = fontsize * .5,
                ## angle = fontangle,
                col = fontcolor, fontface = fontface)) +
  # make sure the font size is set to your liking
  scale_size_identity() +
  scale_colour_identity() +
  # add axis label for age axis
  labs(x = "Age (millions of years ago)") +
  theme(
    # remove gray panel
    panel.grid = element_blank(),
    panel.background = element_blank(),
    # remove y axis entirely
    axis.line.y = element_blank(),
    axis.title.y = element_blank(),
    axis.text.y = element_blank(),
    axis.ticks.y = element_blank()) +
  coord_cartesian(xlim = c(0, 40))
gtsplot

imgs/gts_data.png

And to combine the two, make sure they have precisely the same x axis and then join them together using patchwork.

library(patchwork)
(dataplot +
 # make sure that it has precisely the same x axis range
 coord_cartesian(xlim = c(0, 40)) +
 # then remove the redundant x-axis from the data
 theme(axis.text.x = element_blank(), axis.title.x = element_blank())) /
  # and add the gts beneath the data, at a smaller size
  gtsplot + plot_layout(heights = c(1, .05))

imgs/gts_plus_data.png

contributing

If you spot any errors, please feel free to file an issue or write a pull request!

copying

I’ve licensed the code with GPL-3, but the underlying data is copyright of the Geologic Time Scale at https://timescalefoundation.org/

About

Read in the GTS as a csv, then use ggplot2 in R to make a timescale. Use patchwork to add it to your figures.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages