如何改善ggplot?

问题描述 投票:0回答:1

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

enter image description here

我想将每个箱形图标记为样本图中的标记。 sample plot i want to get

enter image description here

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

ggplot(testdata) +
geom_boxplot(aes(x=variable, y=value, color= as.factor (classification)))
r ggplot2 label boxplot
1个回答
0
投票

您可以使用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")
© www.soinside.com 2019 - 2024. All rights reserved.