Plotting a stacked bar plot?

后端 未结 1 693
感动是毒
感动是毒 2020-12-03 23:59

I have the following data:

structure(list(Time = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 
         


        
相关标签:
1条回答
  • 2020-12-04 00:34
    ggplot(df, aes(x = factor(Time), y = Value, fill = factor(Type))) + 
    geom_bar(stat="identity", position = "stack")
    

    enter image description here

     ggplot(df, aes(x = factor(Time), y = Value, fill = factor(Type))) + 
     geom_bar(stat="identity", position = "dodge")
    

    enter image description here

    You can do one or the other but not both. When they are dodged, the different values of type are being used. By adding a color outline, you can see that.

     ggplot(df, aes(x = factor(Time), y = Value, fill = factor(Type))) + 
     geom_bar(stat="identity", position = c("dodge"), colour = 'black') 
    

    enter image description here

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