How to automatically adjust the width of each facet for facet_wrap?

后端 未结 3 1274
情深已故
情深已故 2020-12-29 15:07

I want to plot a boxplot using ggplot2, and i have more than one facet, each facet has different terms, as follows:

library(ggplot2)

  p <- ggplot(
    d         


        
3条回答
  •  余生分开走
    2020-12-29 15:44

    In general, you can determine the width of a box plot in ggplot like so:

    ggplot(data= df, aes(x = `some x`, y = `some y`)) + geom_boxplot(width = `some witdth`)
    

    In your case, you might consider setting the width of all the box plots to the range of x divided by the maximum number of elements (in the leftmost figure).

提交回复
热议问题