Last active
March 17, 2020 17:29
-
-
Save padpadpadpad/7edeba83bccc7e730cefcf6cc1077f73 to your computer and use it in GitHub Desktop.
Example of using plotmath in ggplot2 facet labels
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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