Comments (6)
A valid question. I was thinking the same.
Update:
I have three levels and have only used one level (0.2) in this example. Using all would required group-wise / fill-wise comparisons (??).
subs5_freq %>%
group_by(breed, study_area, level ,veg_class) %>%
filter(level == 0.2) %>%
ggplot(aes(x=factor(veg_class), y=freq, fill=factor(level))) +
geom_boxplot(width = 0.75, position = position_dodge(width = .9)) +
facet_grid(study_area~breed) +
geom_signif(comparisons = list(c("1_lessgood", "2_good"),
c("2_good", "3_verygood"),
c("1_lessgood", "3_verygood")),
test = "wilcox.test", map_signif_level=TRUE)
In this case however, it would be nice if the somparisons would be stacked
from ggsignif.
Something like this?
ggplot(mpg, aes(class, hwy)) +
geom_boxplot() +
facet_grid(.~type) +
geom_signif(comparisons = list(c("2seater", "compact")), map_signif_level=TRUE)
from ggsignif.
This is what I'm aiming for:
Update:
Note that while this is possible, its not really what I want.
ggplot(mpg, aes(type, hwy)) +
geom_boxplot() +
facet_grid(.~class) +
geom_signif(comparisons = list(c("auto", "manual")), map_signif_level=TRUE)
from ggsignif.
Hi @G-Thomson,
I am afraid it not possible to draw anything across facets, as long as you stay within the ggplot2 framework. But ggplot is build upon gtables, so you can use that package to draw across facet. Here is an answer on stackoverflow demonstrating the basics. But this is something I cannot facilitate with my package.
@vestlink, if I understand you correctly you want to do comparison of groups that are drawn with geom_boxplot(position = "dodge")
. Unfortunately this is not automatically because the dodging draws at some to geom_signif
unknown location. So it would be necessary to draw the comparisons manually as I did in the advanced example in the README.md. Now you have the further complication that you probably want to draw different brackets per facet. The best code I found to do this looks like this:
ggplot(mpg, aes(type, hwy)) +
geom_boxplot() +
geom_signif(data=data.frame(class=c("2seater", "midsize"), type=0, hwy=0, group=1), aes(group=group), annotations="abc", y_position = 46, xmin=1, xmax=2)+
geom_signif(data=data.frame(class=c("minivan"), type=0, hwy=0, group=1), aes(group=group), annotations="123", y_position = 46, xmin=1, xmax=2)+
facet_grid(.~class)
As this is all pretty complicated I would suggest to just create a new variable that combines the veg_class
and level
. So the new code would like this:
iris %>%
mutate(Variable=paste0(Species, "-", Petal.Width > 1)) %>%
ggplot(aes(x=Variable, y=Sepal.Width, fill=Petal.Width > 1)) +
geom_boxplot() +
geom_signif(comparisons = list(c("setosa-FALSE", "versicolor-FALSE"))) +
facet_wrap(~ I(Sepal.Length > 5.0))
from ggsignif.
@const-ae Thank you for your comments. It is true that things get complicated across facets. I will study the code and suggestions further...
from ggsignif.
@const-ae Thanks for getting back to me.
from ggsignif.
Related Issues (20)
- Figure out where the `WARNING`s and `NOTE`s in `R CMD check` are coming from HOT 1
- Manual vertical brackets do not work: "arguments imply differing number of rows" HOT 1
- Warning message: Ignoring unknown aesthetics: xmin, xmax, annotations, y_position HOT 3
- adding scale_y_log10 changes y-axis to a weird range
- geom_signif does not plot comparison on the facetted plot with free x scale HOT 2
- Where can we find the significance level in the ggplot object slots? HOT 1
- Rename default branch from `master` to `main` HOT 3
- CRAN release 0.6.4 HOT 3
- Correcting for multiple testing when using geom_signif HOT 5
- Feature request - add more distance between comparisons and data HOT 4
- geom_signif - all comparisons dissappear when one comparison has missings HOT 2
- Significance stars are misaligned when using "NS" as well
- ggsignif results don't match with anova significance HOT 1
- Use cross symbol when p <.10?
- what are * , ** , *** correspond if specific values by user is not given? HOT 1
- How do I hide the no significant (NS) comparisons?
- Adding significance bar on coupled boxplots
- FDR warning HOT 1
- Show exact p value in comparisons HOT 3
- ggsignif facetting issue - Missing significance labels in certain facets
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ggsignif.