stacked bars within grouped bar chart

前端 未结 1 561
逝去的感伤
逝去的感伤 2020-11-30 04:37

I have the following graph

test <- expand.grid(\'cat\' = LETTERS[1:5], \'cond\'= c(F,T), \'year\' = 2001:2005)
test$value <- floor((rnorm(nrow(test)))*         


        
相关标签:
1条回答
  • 2020-11-30 04:55

    You can put cat on the x-axis and use facet_grid with year:

    ggplot() +
      geom_bar(data=test, aes(y = value, x = cat, fill = cond), stat="identity",
               position='stack') +
      theme_bw() + 
      facet_grid( ~ year)
    

    enter image description here

    0 讨论(0)
提交回复
热议问题