Skip to content

Instantly share code, notes, and snippets.

@padpadpadpad
Last active March 17, 2020 17:29
Show Gist options
  • Save padpadpadpad/7edeba83bccc7e730cefcf6cc1077f73 to your computer and use it in GitHub Desktop.
Save padpadpadpad/7edeba83bccc7e730cefcf6cc1077f73 to your computer and use it in GitHub Desktop.
Example of using plotmath in ggplot2 facet labels
# load in package
library(ggplot2)
data("mpg")
# create a separate column for the letter in the facet
mpg$letter <- letters[as.numeric(as.factor(mpg$class))]
# plot this
ggplot(mpg, aes(cyl, hwy)) +
geom_point() +
facet_grid(. ~ class + letter , labeller = label_bquote(cols = (.(letter))~italic(.(class))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment