grouped barplot: order x-axis & keep constant bar width, in case of missing levels

前端 未结 4 600
情话喂你
情话喂你 2021-01-21 14:12

Here is my script (example inspired from here and using the reorder option from here):

library(ggplot2)
Animals <- read.table(
  header=TRUE, tex         


        
4条回答
  •  爱一瞬间的悲伤
    2021-01-21 14:37

    To achieve something like that I would adjust the data frame when working with ggplot. Add the missing categories with a value of zero.

    Animals <- rbind(Animals, 
                     data.frame(Category = c("Improved", "Decline"), 
                                Reason = c("Hello", "Bla"), 
                                Species = c(0,0)
                                )
    )
    

提交回复
热议问题