【问题标题】:R: Setting the color for an individual data point in stripchartR:设置条形图中单个数据点的颜色
【发布时间】:2021-05-14 06:42:33
【问题描述】:

我无法在条形图中设置异常值的颜色。我尝试了两种方法,但都没有成功。

代码如下:

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)

颜色都是蓝色,没有变化。

预期的图显示在 minitab 链接中:

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/

【问题讨论】:

    标签: minitab stripchart


    【解决方案1】:

    points() 不适用于条形图。所以使用带有选项'add=TRUE'的stripchart()

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

    【讨论】:

      猜你喜欢
      • 2012-02-05
      • 2020-09-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-11
      • 2020-03-13
      • 2020-04-11
      • 2023-03-18
      相关资源
      最近更新 更多