-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Puzzled for annotation that contain duplicate contents #6
Comments
Hi, ggplot(dat, aes(Group, Value)) +
geom_bar(aes(fill = Sub), stat="identity", position="dodge", width=.5) +
geom_signif(comparisons=list(c("S1", "S2")), annotations="***",
y_position = 9.3, tip_length = 0, vjust=0.4) +
geom_signif(stat="identity",
data=data.frame(x=c(0.875, 1.875), xend=c(1.125, 2.125),
y=c(5.8, 8.5), annotation=c("**", "**")),
aes(x=x,xend=xend, y=y, yend=y, annotation=annotation, group=c(1,2))) +
scale_fill_manual(values = c("grey80", "grey20")) The problem is that currently the data is separated by annotation into different groups and if the annotation is identical for some rows it is assumed that it's just a more complex definition of the bracket. I will see if I can find a better pattern to avoid confusion or I will update the documentation in the next release. |
Identical annotations lead to weird behavior if stat="identity" is used. The problem is that the data is grouped by annotation and identical annotation across rows is assumed to represent complex bracket definitions.
In the new v.0.3.0 release I have extended the capability of the package to put brackets at custom locations, where only dat <- data.frame(Group = c("S1", "S1", "S2", "S2"),
Sub = c("A", "B", "A", "B"),
Value = c(3,5,7,8))
ggplot(dat, aes(Group, Value)) +
geom_bar(aes(fill = Sub), stat="identity", position="dodge", width=.5) +
geom_signif(y_position=c(5.3, 8.3), xmin=c(0.8, 1.8), xmax=c(1.2, 2.2),
annotation=c("**", "NS"), tip_length=0) +
geom_signif(comparisons=list(c("S1", "S2")),
y_position = 9.3, tip_length = 0, vjust=0.2) +
scale_fill_manual(values = c("grey80", "grey20")) This avoids the unnecessary complicated definition of the data.frame and I will close this issue, but you can re-open it if I missed anything. |
Hi Constantin,
The package you provide is exceedingly useful.
But I'm troubled by the function aes(annotation=). The annotation would be merged and drawn on the midpoint coordinate, when the annotation contain duplicate contents.
You can try this code which comes from the site https://cran.r-project.org/web/packages/ggsignif/vignettes/intro.html.
After I modified the content of annotation, the strange result emerged.
geom_signif(stat="identity", data=data.frame(x=c(0.875, 1.875), xend=c(1.125, 2.125), y=c(5.8, 8.5), annotation=c("**", "**")), aes(x=x,xend=xend, y=y, yend=y, annotation=annotation))
Waitting for your solution.
The text was updated successfully, but these errors were encountered: