如何改进ggplot?

how to improve ggplot?

我使用 ggplot2 在 R 中输出箱线图。 box plot i got using the below code

我想将每个箱线图标记为示例图中的标记。 sample plot i want to get

我计算出第一个鸡蛋 1 的 p 值为 0.06。我想将此文本粘贴到示例图中所示的图上。我该怎么做?

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

您可以使用 annotate 在您的箱线图上添加文本:

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