I'm checking out the great new caption feature.
I'd like to place a centre justified caption approx 3/4 of the way horizontally at the bottom of a plot. I (perhaps erroneously), thought that margin would be the correct way to do this.
Top and bottom seem to work fine, but left and right make no difference. Do I have the wrong end of the stick? Example below (I'm using 2.1.0.9000)
library (ggplot2)
df <- data.frame (x=1:10, y=1:10)
# make base plot
p <- ggplot (df, aes (x=x, y=y)) + geom_point()
# make caption with a line break so can be nicely justified
caption_text <- "what an\namazing chart"
# add caption
p <- p + labs (caption=caption_text)
# try to move caption
# top margin works
p <- p + theme (plot.caption=element_text(hjust=0.5, vjust=0.5,
margin=margin(t=100,10,10,10),debug=TRUE))
p
# bottom margin works
p <- p + theme (plot.caption=element_text(hjust=0.5, vjust=0.5,
margin=margin(t=10,10,100,10),debug=TRUE))
p
# Left has no effect
p <- p + theme (plot.caption=element_text(hjust=0.5, vjust=0.5,
margin=margin(t=10,10,10,100),debug=TRUE))
p
# Right has no effect
p <- p + theme (plot.caption=element_text(hjust=0.5, vjust=0.5,
margin=margin(t=10,100,10,10),debug=TRUE))
p