How do I plot charts with nested categories axes?

后端 未结 2 1291
心在旅途
心在旅途 2020-12-11 17:25

I\'m plotting data which have both a category and a sub-category (see the example data below) and I\'d like to display these with them nested (this example was created in Ex

2条回答
  •  余生分开走
    2020-12-11 17:42

    Untested, but try:

    ggplot(data=df, aes(x=second.cat, y=value)) + geom_point() + facet_grid(~ main.cat, scales = 'free')
    

    Albeit, the width of each main.cat would be the same, and the label of same can only be positioned at top.

提交回复
热议问题