I\'m about to plot odds ratios with R/ggplot2 and I want to add two arrows underneath or next to the X-axis label. One pointing to the left, one pointing to the right,
This is a pretty old post, but thought I would share another option for anyone who stumbles upon this.
I have a situation which really requires that I have arrows outside of the plotting region (and don't care to involve grid
). As shown below, using expressions and symbols might be a good option for some:
p1 <- qplot(x = 0:12, y = 0:12, geom = "blank")
p1 <- p1 + ylab(expression(symbol('\256')))
p1 <- p1 + xlab(expression(symbol('\256')))
p1 <- p1 + theme(axis.title.y = element_text(size = 30))
p1 <- p1 + theme(axis.title.x = element_text(size = 30))
p1
The theme modifications aren't absolutely necessary but you will probably want to increase the size of the arrows at least a bit.
By default, the symbol()
function takes Adobe Symbol codes which are outline in this document.
If you want to add some text to the labels (just adding to the expression would probably make it too big), the following should get you started:
grid.text(label="X", x = 0.645, y = 0.02)
grid.text(label="Y", x = 0.1, y = 0.5, rot=90)
grid.gedit("GRID.text", gp=gpar(fontsize=15))