I understand that varwidth = TRUE within ggplot2's geom_boxplot can be used to create proportional boxplots so that each boxplot also summarises the number of points within a plot. However, I am struggling to maintain proportional boxplot sizes whilst also producing multiple plots?
Using the diamonds df in ggplot2 I am trying to reproduce the below image.
What I have tried is this:
ggplot(data = diamonds, mapping = aes(x = carat, y = price)) + geom_boxplot(mapping = aes(group = cut_number(carat, 20), varwidth = TRUE))
I tried to use cut_number to achieve the multiple, and var-width for proportionality. I'd also like to have the boxplots show vertically. I have been stumped on this for hours and have looked online but to no avail. Any tips?