I am trying to display some information about the data below the plot created in ggplot2. I would like to plot the N variable using the X axis coordinate of the plot but the Y coordinate needs to be 10% from the bottom of the screen . In fact, the desired Y coordinates are already in the data frame as y_pos variable.

I can think of 3 approaches using ggplot2:

1) Create an empty plot below the actual plot, use the same scale and then use geom_text to plot the data over the blank plot. This approach sort of works but is extremely complicated.

2) Use geom_text to plot the data but somehow use y coordinate as percent of the screen (10%). This would force the numbers to be displayed below the plot. I can't figure out the proper syntax.

3) Use grid.text to display the text. I can easily set it at the 10% from the bottom of the screen but I can't figure how set the X coordindate to match the plot. I tried to use grconvert to capture the initial X position but could not get that to work as well.

This is getting closer but it's not pretty. In the code below, a base plot is drawn, with a wider margin at the bottom of the plot. The textGrob is created, then inserted into the plot using annotation_custom(). Except the text is not visible because it is outside the plot area - the output is clipped to the plot region. But using baptiste's code from here, the clipping can be overrridden. It uses X and Y from the plot, and both are centred.

Thank you so much!!! I realize that Grid functions allow to place text anywhere on the device. I am just wondering if this possible to place text BELOW the plot, yet somehow use the X coordinates from the plot. i.e something similar to what you could with text function in base R.
–
Max CMay 2 '12 at 0:47