I want to use subscripts within each factor in a ggplot barplot.
d = structure(list(env = structure(c(1L, 3L, 4L, 2L, 5L, 7L, 6L), .Label = c("mean SS",
"50% O2 @ 25 °C", "50% O2 @ 0 °C", "50% O2 @ 10 °C", "anoxic @ 0 °C",
"anoxic @ 25 °C", "anoxic @ 10 °C"), class = "factor"), pco2_inc = c(60,
138.652445968464, 144.328210839879, 112.560395996095, 173.615572249453,
234.86228704132, 209.102964222973)), class = "data.frame", row.names = c(NA,
-7L))
Given the data.frame above, I want to produce a plot like this:
ggplot(d, aes(env, pco2_inc)) + geom_col()
How can I make the 2
in O2
subscripted for all the bar labels?
I've seen how the entire x axis label can be changed:
labs(x = expression(paste('50% ', O[2], ' @ 0 °C')))
but can't find how to get the axis.text
to work.
Error in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : polygon edge not found
– Trim