代码之家  ›  专栏  ›  技术社区  ›  yenats

“barplot:col”不接受颜色向量

  •  0
  • yenats  · 技术社区  · 8 年前

    mat

    A B C D 254 146 83 75

    并以不同颜色显示条形图。然而,喂食时 barplot

    barplot (mat, col=c("blue","red","blue","red"))

    看起来像这样:

    enter image description here

    我做错什么了吗?

    2 回复  |  直到 8 年前
        1
  •  0
  •   Abhishek Gurjar    6 年前

    mat <- data.frame(mat)
    
    barplot(mat,col=c("blue","red","blue","red"))
    

    版本2

    mat <- c(254 , 146  ,  83 ,   75)
    
    barplot(mat,col=c("blue","red","blue","red"))
    
        2
  •  0
  •   yenats    6 年前

    为了省去条形图,以为它是在做叠加条形图(每个条形图只有一个值),我使用了:

    barplot (mat, col=c("blue","red","blue","red"), beside=TRUE)