Skip to content

Instantly share code, notes, and snippets.

@riinuots
Last active July 31, 2017 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save riinuots/25817167cfd397cacecdf6f38b473392 to your computer and use it in GitHub Desktop.
Save riinuots/25817167cfd397cacecdf6f38b473392 to your computer and use it in GitHub Desktop.
library(ggplot2)
#example dataset:
mydata = data.frame(x = 1:10, y=1:10
, cat = c(rep('first', 3), rep('second', 3), rep('third', 4)))
#create (a), (b), ...
my_plotlabels = paste0('(', letters, ') ')
#paste plot labels together with the levels of the variable used for faceting
levels(mydata$cat) = paste0(my_plotlabels[1:length(levels(mydata$cat))]
, levels(mydata$cat))
ggplot(mydata, aes(x=x, y=y))+
facet_wrap(~cat)+
geom_point(size=2, shape=7)+
theme_bw()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment