Skip to content

Instantly share code, notes, and snippets.

@andrewheiss
Created June 14, 2019 22:16
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewheiss/93f3da5d6daa8c10c37cc97d8c8d83ab to your computer and use it in GitHub Desktop.
Save andrewheiss/93f3da5d6daa8c10c37cc97d8c8d83ab to your computer and use it in GitHub Desktop.
library(tidyverse)

# See https://stackoverflow.com/a/17313561/120898
pts <- function(x) {
  as.numeric(grid::convertUnit(grid::unit(x, "pt"), "mm"))
}

df <- tibble(x = 1:10, y = 1:10)

ggplot(df, aes(x = x, y = y)) +
  geom_point() + 
  annotate(geom = "text", x = 2, y = 5, label = "I'm 10 points",
           size = pts(10)) +
  annotate(geom = "text", x = 2, y = 8, label = "I'm 5 points",
           size = pts(5))

Created on 2019-06-14 by the reprex package (v0.3.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment