2014-09-01 31 views
2

我无法将barplot中的归因颜色归为行,但它们不存在。当我使用命令:在一个barplot中按行排列属性颜色

barplot(data[,3:429]) 

它确实给我在高度方面正确的模式,但它是全黑的。我有22个不同的行(每个行有427个变量),但那些行并没有在我的情节中识别。

数据的一小部分是这样的:

VT ATC V4 V5 V6 V7 V8 V9 V10 V11 V12 .... V429 
1 1 0 1 1 2 2 2 2 1 1 
1 2 0 1 1 1 1 1 1 1 1 
1 3 0 0 0 0 0 0 0 0 0 
1 4 0 0 0 0 0 0 0 0 0 
1 5 0 0 0 1 1 1 1 0 0 

我尝试添加的颜色,但它并没有这样的工作:

barplot(data[,3:429],col=c("blue", "aliceblue","antiquewhite", "antiquewhite1","antiquewhite2","antiquewhite3", "antiquewhite4","aquamarine","aquamarine1","aquamarine2", "aquamarine3", "aquamarine4", "darkgreen", "darkgrey","darkkhaki","darkmagenta", "darkolivegreen","darkolivegreen1","darkolivegreen2","darkolivegreen3","darkolivegreen4","darkorange")) 

的22种颜色随机选择,对他们没有具体的意义。

我在做什么错?

回答

1

我以下工作:

#dummy data 
m <- matrix(sample(1:10,500*22,replace=TRUE),ncol=500) 

#stacked bar plot with colours 
barplot(m[,3:400], 
     col=c("blue", "aliceblue","antiquewhite", "antiquewhite1","antiquewhite2","antiquewhite3", "antiquewhite4","aquamarine","aquamarine1","aquamarine2", "aquamarine3", "aquamarine4", "darkgreen", "darkgrey","darkkhaki","darkmagenta", "darkolivegreen","darkolivegreen1","darkolivegreen2","darkolivegreen3","darkolivegreen4","darkorange"), 
     border = FALSE, space=0 
     ) 

这是你希望得到什么?

enter image description here

+0

是的,非常相似,只有22色和x轴427值。但这是我正在寻找的。为什么不开采工作?我确定它也是一个矩阵。 – 2014-09-01 13:40:36

+0

在barplot中设置'border = FALSE'。 – zx8754 2014-09-01 13:45:05

+0

伎俩 – 2014-09-01 13:49:04