简体   繁体   English

如何使用 R 在箱线图上显示特定的已知值?

[英]How can I show a specific known value on the boxplot using R?

To be more specific, I have one value as a result of my analysis and I want to show where this specific value correspondence on the related boxplot.更具体地说,我的分析结果有一个值,我想在相关的箱线图中显示此特定值对应的位置。箱形图

I want to get something like the image.我想得到类似图像的东西。 The red point will be the result of my analysis.红点将是我的分析结果。 Thank you in advance.先感谢您。

Create a new data frame with the points you want to mark and use geom_point .使用要标记的点创建一个新数据框并使用geom_point

library(ggplot2)

ggplot(mpg, aes("", hwy)) +
  geom_boxplot() +
  geom_point(data = data.frame(hwy = 30), color = "red")

箱形图

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM