Faceting Attributes - brodieG/ggplot2 GitHub Wiki

Faceting Attributes

Return to opts() list

Base Plot

#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

http://imgur.com/8xwsr.png

strip.background (rect)

#
plot + theme(strip.background = element_rect(colour = 'purple', fill = 'pink', size = 3, linetype='dashed'))

http://imgur.com/noPV7.png

strip.text.x (text)

#
plot + theme(strip.text.x = element_text(colour = 'red', angle = 45, size = 10, hjust = 0.5, vjust = 0.5, face = 'bold'))

http://imgur.com/kmIRQ.png

strip.text.y (text)

#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'))

http://imgur.com/xAWsW.png #panel.margin ()

#big margins
plot + theme(panel.margin=unit(5 , "lines"))
#no margins
plot + theme(panel.margin=unit(0 , "lines"))

http://imgur.com/4BVHq.pnghttp://imgur.com/eUBCH.png