我在条形图中设置异常值的颜色时遇到了问题。我尝试了两种方法,但都不起作用。
这是代码:
x = rnorm(30)
x[20]=10
# 1
stripchart(x,main='Outlier Plot',xlab='x', pch=20, col=ifelse(x==10, 'red', 'blue'))
# 2
cols = rep('blue',length(x))
cols[which(x==10)]='red'
stripchart(x,main='Outlier Plot',xlab='x', pch=20, col=cols)
所有的颜色都是蓝色的,没有变化。
预期的绘图显示在迷你标签链接中:
https://support.minitab.com/en-us/minitab/20/help-and-how-to/statistics/basic-statistics/how-to/outlier-test/perform-the-analysis/select-the-graph/
points((不适用于条形图。因此,使用stripchart((和选项'add=TRUE'
stripchart(x,pch=20,col='blue')
stripchart(x[11],col='red',pch=20, add=TRUE)