-
Notifications
You must be signed in to change notification settings - Fork 2k
Faceting Attributes
Mara Averick edited this page Nov 2, 2018
·
7 revisions
Note: The ggplot2 wiki is no longer maintained, please use the ggplot2 website instead!
#create simple dataframe for plotting
xy <- data.frame(x = rep(1:10, times=3), y = rep(10:1, times=3), type = rep(LETTERS[1:2], each=5), type2 = rep(LETTERS[3:5], each=10))
#create base plot
plot <- ggplot(data = xy)+
geom_point(aes(x = x, y = y))+
facet_grid(type ~ type2)
#plot base plot
plot
#
plot + theme(strip.background = element_rect(colour = 'purple', fill = 'pink', size = 3, linetype='dashed'))
#
plot + theme(strip.text.x = element_text(colour = 'red', angle = 45, size = 10, hjust = 0.5, vjust = 0.5, face = 'bold'))
#color doesn't work, need colour
plot + theme(strip.text.y = element_text(colour = 'red', angle = 45, size = 10, hjust = 0.5, vjust = 0.75, face = 'italic'))
#panel.margin ()
#big margins
plot + theme(panel.margin=unit(5 , "lines"))
#no margins
plot + theme(panel.margin=unit(0 , "lines"))