[R] Adding annotations to qplot from a data frame

Euan Reavie euan.reavie at gmail.com
Sun Sep 16 17:09:43 CEST 2012


Thank you for the many replies on this issue. I turns out qplot is not
suited to multiple annotations, so the best suggestions were to use
ggplot. The following worked for making an annotated stacked bar plot:

ggplot(algaedata) +
    geom_bar(aes(x = year, y = cellsperml, colour = DIV, group = DIV)) +
    geom_text(data = labelstouse, aes(x = x, y = y, label = numb))

Dennis Murphy additionally suggested using a combined line and point
plot by using the following instead:

    geom_point(aes(x = year, y = cellsperml, colour = DIV, group = DIV)) +
    geom_line(aes(x = year, y = cellsperml, colour = DIV, group = DIV))

All the best - Euan.




More information about the R-help mailing list