I am trying to increase the space between box plots in a diagram generated by ggplot2
. I found an answer to how to do it for barplots which I was not able to adapt but which at least makes me more hopeful. I have the following code:
library('ggplot2')
FOO <- runif(30, min=0, max=10);
BAR <- rep(c("a", "b", "c"), 10)
df <- data.frame(FOO, BAR);
ggplot(df, aes(x = BAR, y = FOO)) + geom_boxplot(outlier.shape = NA, fill = "grey80",alpha = 0.3) + geom_point(position = position_jitter(w = 0.5, h = 0)) + theme_bw()
It is really difficult to see which dataset the dots belong to. I realise that I can change the w
in the position_jitter
but that also increases the risk of overlap. I would like to also be able to increase the space between the plots. How can this be done?
I don't understand this plot and don't think it will become better, even if you increase the space between the groups:
ggplot(df, aes(x = BAR, y = FOO)) +
geom_boxplot(outlier.shape = NA, fill = "grey80",alpha = 0.3, width=0.5) +
geom_point(position = position_jitter(w = 0.15, h = 0)) +
theme_bw()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.