Usman
Usman

Reputation: 29

how to improve ggplot?

I have a boxplot output in R using ggplot2. box plot i got using the below code

enter image description here

I want to label each box plot as labelled in the sample plot. sample plot i want to get

enter image description here

I have calculated p-value that is 0.06 for first egg1. i would like to paste this text on the plot as shown in the sample plot. how i can do that?

ggplot(testdata) +
geom_boxplot(aes(x=variable, y=value, color= as.factor (classification)))

Upvotes: 1

Views: 69

Answers (1)

dc37
dc37

Reputation: 16178

You can use annotate to add text on your boxplot:

ggplot(testdata) +
geom_boxplot(aes(x=variable, y=value, color= as.factor (classification))) +
annotate(geom="text", x=1, y=6, label="p = 0.06")

Upvotes: 1

Related Questions