R 在ggplot中使用道奇获得箱线图的x位置

R 在ggplot中使用道奇获得箱线图的x位置,r,ggplot2,R,Ggplot2,嘿,我想在应用躲避时访问箱线图的确切位置,如下所示: testPlot <- ggplot(iris, aes(x=Species, y=Sepal.Width, fill=Petal.Width > 1)) + geom_boxplot(position="dodge") testPlot testPlot 1))+ 几何箱线图(位置=“道奇”) 试验图 例如,这一点很重要,这样就可以在一个框的正上方添加注释,而无需修改。我在str(testPlot)中找不到任何东西。检

嘿,我想在应用躲避时访问箱线图的确切位置,如下所示:

testPlot <- ggplot(iris, aes(x=Species, y=Sepal.Width, fill=Petal.Width > 1)) +
  geom_boxplot(position="dodge")
testPlot
testPlot 1))+
几何箱线图(位置=“道奇”)
试验图


例如,这一点很重要,这样就可以在一个框的正上方添加注释,而无需修改。我在
str(testPlot)
中找不到任何东西。检查
ggplot\u build(testPlot)
的输出可以为您提供用于绘制箱线图的数据。这是输出

#$data[[1]]
#填充ymin中下部上部ymax异常值notchupper notchlower x面板组ymin_final ymax_final xmin xmax重量颜色大小alpha形状线型
#1#F8766D 2.9 3.20 3.4 3.675 4.2 4.4,2.3 3.506137 3.293863 1.0000 1 1 2.3 4.4 0.625 1.375 1灰色20 0.5 NA 19固体
#2#00BFC4 2.3 2.70 2.9 3.000 3.4 2.2 2 2.972284 2.827716 2.1875 1 3.2 3.4 2.000 2.375 1灰色20 0.5 NA 19固体
#3 35; F8766D 2.0 2.25 2.4 2.500 2.7 2.549296 2.250704 1.8125 1 2.0 2.7 1.625 2.000 1灰色20 0.5 NA 19固体
#4#00BFC4 2.5 2.80 3.0 3.175 3.6 3.8、2.2、3.8 3.083792 2.916208 3.0000 1 4 2.2 3.8 2.625 3.375 1灰色20 0.5 NA 19固体
# -------------------------------------------------------------------------
例如,使用这些信息,我们可以在特定位置的
[1]
箱线图顶部注释文本,如下所示

testPlot+注释(geom=“text”,x=1,y=3.3,label=“此处示例文本”,
color=“蓝色”)
我如何找到坐标
(1,3.3)
?如果你仔细看第一行,你可以看到下一行
(Q1)也就是第一个四分位数
3.20和
y
之间,介于
2.9和
4.2之间。您还可以看到异常值的值。
x
值介于
0.625
1.375
之间。您可以遵循相同的原则并注释所需的箱线图

输出


希望能有所帮助。

太好了,这正是我想要的信息。