Closed cperk closed 5 years ago
I have the same issue. There should be some vertical padding between the lines rather than overlaying them all at the same y_position
. I was trying to do this manually, but going much above the graph causes the ggsignif
annotations to disappear altogether.
A solution for this would be great.. seems like a fairly basic feature for the package.
Sorry for the late reply (I know this is probably irrelevant for you now, but just for future reference).
There is a simple option available to automatically increase the distance between each line called step_increase
.
library(ggplot2)
library(ggsignif)
ggplot(mpg, aes(class, hwy)) +
geom_boxplot() +
geom_signif(comparisons = list(c("2seater", "compact"), c("2seater", "midsize"),
c("2seater", "minivan"), c("2seater", "pickup"),
c("2seater", "subcompact"), c("2seater", "suv")),
annotation="***", color="red", step_increase = 0.1)
Created on 2019-02-20 by the reprex package (v0.2.1)
Hi Constantin,
As you noted here, step_increase
in a great feature of your very nice package. However, I found that step_increase
is not compatible with y_position
. Here's an example based on your example above:
library(ggplot2) library(ggsignif) ggplot(mpg, aes(class, hwy)) + geom_boxplot() + geom_signif(comparisons = list(c("2seater", "compact"), c("2seater", "midsize"), c("2seater", "minivan"), c("2seater", "pickup"), c("2seater", "subcompact"), c("2seater", "suv")), annotation="***", color="red", y_position = 50, step_increase = 0.1)
The reason that I'd like to combine y_position
with step_increase
is that I am drawing several plots at once,using a consistent y axis. I'd therefore like to specify a consistent y_position
too, to have the significance brackets positioned identically in all plots. Do you think that's possible? Without specifying the different y_position
values "manually"?
Best regards,
Anton
Hi ACMGlueck,
you are right that should be the expected behavior. I have implemented a fix (https://github.com/const-ae/ggsignif/commit/8e86adfec95828d6098f836ff5cd8969def032dd).
library(ggplot2)
library(ggsignif)
ggplot(mpg, aes(class, hwy)) +
geom_boxplot() +
geom_signif(comparisons = list(c("2seater", "compact"),
c("2seater", "midsize"),
c("2seater", "minivan"),
c("2seater", "pickup"),
c("2seater", "subcompact"),
c("2seater", "suv")),
annotation="***", color="red",
y_position = 50, step_increase = 0.1)
Created on 2019-11-08 by the reprex package (v0.3.0)
I hope this addresses your issue. To use the fix, make sure that you install the latest development version from Github:
devtools::install_github("const-ae/ggsignif")
Best Regards, Constantin
Hi Constantin, Great - that's perfect! Problem resolved! And thanks for fixing this so quickly!!!
I find that the significance stars do not line up well between each comparison. There are a lot of stars clumped together.
Here is some reproducible code using the mpg dataset. I want to show significance in the boxplot, named p, between 2seater and all the other cars:
p <- ggplot(mpg, aes(class, hwy))
p + geom_boxplot()+geom_signif(comparisons = list(c("2seater", "compact"), c("2seater", "midsize"), c("2seater", "minivan"), c("2seater", "pickup"), c("2seater", "subcompact"), c("2seater", "suv")), annotation="***", color="red",y_position = 40)
Unfortunately the signficance stars are not spread out properly:
It is also kind of hard to tell which pairs I am comparing. Do you have any suggestions to fix?
Thanks so much!!