I have a figure that looks like this:
Initial Plot
I am trying to increase the size of the asterisks, using this code:
ggplot(data, aes(x = Cohort, y = C1M_HP, fill = Cohort)) + geom_violin(width = 0.5) +
geom_boxplot(outlier.shape = NA, width = 0.2, coef = 0) +
geom_signif(comparisons = list(c("Control","Dup")), map_signif_level=TRUE, textsize = 6.25) +
scale_fill_manual(values = c('#AED6F1', '#F1948A')) + theme_minimal() +
geom_jitter(alpha = 0.8, width = 0.1)
Unfortunately, this results in the asterisks getting cut off, like so:
Increased asterisk size
I have tried using plot.margin to change the margin sizes, but this is not correct.
How do I add extra ’empty space’ around the edges of my plot to prevent this issue?
>Solution :
One way is to use coord_cartesian(ylim = c(ymin, ymax))
library(ggplot2)
library(ggsignif)
ggplot(mtcars, aes(x = factor(am), y = mpg, fill = factor(am))) + geom_violin(width = 0.5) +
geom_boxplot(outlier.shape = NA, width = 0.2, coef = 0) +
geom_signif(comparisons = list(c("0","1")), map_signif_level=TRUE, textsize = 10.25) +
scale_fill_manual(values = c('#AED6F1', '#F1948A')) + theme_minimal() +
geom_jitter(alpha = 0.8, width = 0.1)+
theme_minimal()+
coord_cartesian(ylim = c(0, max(mtcars$mpg)+5))
