Multirow axis labels with nested grouping variables

前端 未结 6 2028
后悔当初
后悔当初 2020-11-22 16:42

I would like the levels of two different nested grouping variables to appear on separate lines below the plot, and not in the legend. What I have right now is this code:

6条回答
  •  被撕碎了的回忆
    2020-11-22 17:05

    A very simple solution which gives a similar (though not identical) result is to use faceting. The downside is that the Category label is above rather than below.

    ggplot(data=data, aes(x=Group, y=Value, fill=Group)) +
      geom_bar(position = 'dodge', stat="identity") +
      geom_text(aes(label=paste(Value, "%")), position=position_dodge(width=0.9), vjust=-0.25) + 
      facet_grid(. ~ Category) + 
      theme(legend.position="none")
    

    Using faceting to provide secondary label

提交回复
热议问题