Building on my previous question I'd like to add second axis label on the opposite side of the plot.
The data frame looks like:
test <- structure(list(characteristic = structure(c(1L, 2L, 3L, 1L, 2L
), .Label = c("Factor1", "Factor2", "Factor3"), class = "factor"),
es = c(1.2, 1.4, 1.6, 1.3, 1.5), ci_low = c(1.1, 1.3, 1.5,
1.2, 1.4), ci_upp = c(1.3, 1.5, 1.7, 1.4, 1.6), label = structure(c(1L,
3L, 5L, 2L, 4L), .Label = c("1.2 (1.1, 1.3)", "1.3 (1.2, 1.4)",
"1.4 (1.3, 1.5)", "1.5 (1.4, 1.6)", "1.6 (1.5, 1.7)"), class = "factor"),
set = structure(c(1L, 1L, 1L, 2L, 2L), .Label = c("H", "S"
), class = "factor")), .Names = c("characteristic", "es",
"ci_low", "ci_upp", "label", "set"), class = "data.frame", row.names = c(NA,
-5L))
Using Tyler's solution, a graph of it looks like that at the moment:
In a similar way to a forest plot I'd like to add a second set of labels (label
variable in my data frame) representing graphed values, preferably on the right side of panels. So that it all mimics forest plot similar to this example:
I know that second axis seems to be frowned upon. However these are just another set of labels.. ant it seems to be a custom among forest plots.
How can I do that in ggplot?
Best Answer
EDIT updating to ggplot2 0.9.3
Adding your set of labels in your test dataframe to the faceted chart is straightforward. Use
geom_text
with aesthetics for the labels, and the x and y positions of the labels. In the code below,xlim
creates a little more space for the labels. The following code:produces: