0

I have trouble in setting the color of an outlier in a stripchart. I tried two method, but neither worked.

Here is the code:

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)

The colors are all blue with no change.

The expected plot was shown in the minitab link:

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/

bert bruynooghe
  • 2,985
  • 1
  • 20
  • 18
ppppppppp
  • 3
  • 2

1 Answers1

0

points() does not work with stripchart. So use stripchart() with the option 'add=TRUE'

    stripchart(x,pch=20,col='blue')
    stripchart(x[11],col='red',pch=20, add=TRUE)
ppppppppp
  • 3
  • 2