Emily
Emily

Reputation: 25

Adding texts to boxplot - ggplot2

enter image description here

I would like to manually add text to indicate significant differences on my graphs by adding letters (e.g. a, b and c) over specific locations on my boxplot using ggplot2. So essentially, I want to be able to add text where I want on the plot.

I have added an example of a graph in the picture above. I have entered the letters (a,b,c) manually in Microsoft Word but I would like to be able to do this in R. Can someone please help? Thank you

Upvotes: 1

Views: 1716

Answers (3)

Shawn Hemelstrand
Shawn Hemelstrand

Reputation: 3228

Alternatively, you can try this. "Data" and "variable" are just names for what you would put in:

ggplot(data,aes(x=variable))+
    geom_boxplot(aes(y=variable2),color="variable")

Upvotes: 0

TarJae
TarJae

Reputation: 78927

just add this line to your code:

annotate("text", x = 3, y=10, label = "whatever")
 

Upvotes: 1

dy_by
dy_by

Reputation: 1241

use ggplot(...) + geom_text() from ggplot2.

Upvotes: 1

Related Questions