[英]How can I visualize specific data points in a boxplot in R?
I have some monthly time-series data and I need to create a boxplot on this data using R.我有一些每月的时间序列数据,我需要使用 R 在这些数据上创建一个箱线图。 Until here, no problem of course.
直到这里,当然没有问题。 Then, additionally to the median, 1st quartile and 3rd quartile, I also need to visualize in the graph specific data points coming from the time-series, namely the observations at 3 years, 1 year and 3 months in the past.
然后,除了中位数、第一四分位数和第三四分位数之外,我还需要在图表中可视化来自时间序列的特定数据点,即过去 3 年、1 年和 3 个月的观察结果。 I looked online but I can't seem to find any command for this.
我在网上查看,但似乎找不到任何命令。 Is there a way I can add these observation to the boxplot?
有没有办法可以将这些观察结果添加到箱线图中?
You can use, for example, the text
function:例如,您可以使用
text
function:
set.seed(123)
x <- rnorm(100, 5, 10)
If you want to display the mean value:如果要显示平均值:
boxplot(x)
text(1, mean(x), "x", col = "red")
Additionally or alternatively, you can use the function points
:另外或替代地,您可以使用 function
points
:
points(IQR(x), col = "blue", pch = 8)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.