How to create geom_boxplot with large amount of continuous x-variables

后端 未结 2 1745
刺人心
刺人心 2020-12-29 06:48

I have a data frame which contains x-axis numeric bins and continuous y-axis data across multiple categories. Initially, I created a boxplot by making the x-axis bins \"fact

2条回答
  •  春和景丽
    2020-12-29 07:14

    Don't make x a factor. You need to aesthetically map a group that is a factor determining which box the value is associated with, luckily, after melting, this is what you variable column is:

    ggplot(df.m, aes(x = x, y = value, group = variable)) +
        geom_boxplot()
    

    As x is still numeric, you can give it whatever values you want within a specific variable level and the boxplot will show up at that spot. Or you could transform the x axis, etc.

提交回复
热议问题