I have a situation (not the example here) where I want to put auxiliary information in a plot between the left vertical axis and the data that are actually plotted. Here is a toy example -- a dumb-looking plot, but illustrates the problem. First, a toy dataset:
toy = data.frame(group = rep(LETTERS[1:2], each = 5),
treat = rep(letters[1:5], 2),
score = c(57, 68, 49, 88, 75, 52, 69, 54, 90, 72),
time = c(23.5, 14.9, 64.2, 34.8, 31.1, 56.9, 45.5, 32.7, 22.0, 45.3))
And the code:
library(ggplot2)
ggplot(data = toy, aes(x = score, y = treat)) +
geom_tile() + geom_tile(aes(x = 32)) +
facet_grid(. ~ group) +
geom_label(aes_(x = 30, label = ~time, hjust = "right"))
At the scale shown, the labels are only partly visible. They are completely visible if I resize the plot window to full-screen. But I need the labels to fit and be fully visible between the left end of the data and the vertical axis for any reasonable sizing of the plot window.
I could add an invisible point at a smaller x value to make more room, but the labels are fixed size, so what x to use depends on how the plot is sized. Also, it would be nice if the size of these labels does not shrink if I make the window smaller -- just like the tick labels and so forth all stay the same size. (In fact, it's kind of like having an additional vertical axis in each panel, with different labels). Any suggestions?