0

我正在尝试使用 4 种不同颜色制作数据集的 barplot2(上传时间太长)。问题是,只有 3/4 是彩色的,它跳过了第一条。我在谷歌上搜索过我写的是否正确,但它应该是正确的。我也试过用数字而不是名字来写颜色

col = 3:4:5:6

但我得到了相同的结果,它跳过了第一个小节。

我尝试过的: 在提出问题之前,我已经在 Stackoverflow 上查看过,但我没有找到解决问题的方法,而且我也尝试过 Google。由于我的数据集太长,我只会上传相关代码,我希望你喜欢:)

## Barplot
library(gplots)
CIA <- t.test(tmp3)$conf.int
CIB <- t.test(tmp5)$conf.int
CIC <- t.test(tmp10)$conf.int
CID <- t.test(tmp17)$conf.int
lower <- c(CIA[1], CIB[1], CIC[1], CID[1])
upper <- c(CIA[2], CIB[2], CIC[2], CID[2])

## install.packages( pkgs= "gplots")

barplot2(c(mean3, mean5, mean10, mean17), 
plot.ci = TRUE, ci.l = lower, ci.u = upper, 
col = c("red", "blue", "yellow", "pink"), 
main ="House 3 & 5 overlap", ylim= c(0,6), 
names = c("3","5","10","17"))

结果:

编辑:没有na的:

在此处输入图像描述

4

1 回答 1

2

tl; dr您可能对NA第一个条的高度有一个值。

使用这个可重现的示例,我无法复制:

library(gplots)
lower <- c(1,2,3,4)
upper <- c(3,4,5,6)

barplot2(c(2,3,4,5),
         plot.ci = TRUE, ci.l = lower, ci.u = upper, 
         col = c("red", "blue", "yellow", "pink"), 
         main ="House 3 & 5 overlap", ylim= c(0,6), 
         names = c("3","5","10","17"))

在此处输入图像描述

这是gplots2.17.0,R-devel。

但是NA,如果我使用第一个值重新绘制绘图,我会得到与您的非常相似的结果:

barplot2(c(NA,3,4,5),
         plot.ci = TRUE, ci.l = lower, ci.u = upper, 
         col = c("red", "blue", "yellow", "pink"), 
         main ="House 3 & 5 overlap", ylim= c(0,6), 
         names = c("3","5","10","17"))

在此处输入图像描述

于 2015-11-09T15:07:42.327 回答