Comments (3)
Hi,
specifying label.y
in aes() is not supported.
You can do this:
ggplot(test, aes(x=group, y = values, fill=group)) +
geom_boxplot() +
geom_blank(aes(y=ymax*3))+
facet_wrap(~vars, scales = 'free') +
stat_compare_means(comparisons=list(c("A","B")), label.y = 20)
When scales = 'free', it's even better to use label.y.npc
:
ggplot(test, aes(x=group, y = values, fill=group)) +
geom_boxplot() +
geom_blank(aes(y=ymax*3))+
facet_wrap(~vars, scales = 'free') +
stat_compare_means(label.y.npc = 0.4)
Let's keep this issue open, I need to improve annotation of the different facet panels
from ggpubr.
Thanks @kassambara .
Surprisingly enough, label.y.npc
does not work when I specify the comparisons.
This code
geom_boxplot() +
geom_blank(aes(y=ymax*3))+
facet_wrap(~vars, scales = 'free') +
stat_compare_means(comparisons=list(c("A","B")),label.y.npc = 0.4)
actually still returns the labels at the top:
from ggpubr.
now, you can compute p-value and add it manually at any position.
In the following example, we'll use the ToothGrowth data. We'll compare supp
levels after grouping the data by dose
.
# Statistical test
library("rstatix") # https://github.com/kassambara/rstatix
stat.test <- ToothGrowth %>%
group_by(dose) %>%
t_test(len ~ supp) %>%
adjust_pvalue() %>%
add_significance("p.adj")
stat.test
# A tibble: 3 x 9 dose .y. group1 group2 statistic p method p.adj p.adj.signif 1 0.5 len OJ VC 3.1697328 0.0064 T-test 0.0128 * 2 1.0 len OJ VC 4.0327696 0.0010 T-test 0.0030 ** 3 2.0 len OJ VC -0.0461361 0.9600 T-test 0.9600 ns
# Visualization
library(ggpubr)
ggboxplot(
ToothGrowth, x = "supp", y = "len",
color = "supp", palette = "jco",
ylim = c(0, 40)
) +
facet_wrap(~dose) +
stat_pvalue_manual(stat.test, label = "p.adj", y.position = 35)
Note that, the option y.position
can be a numeric vector with length = the nombre of p-values to add. It can be also a column name in the stat.test data frame.
from ggpubr.
Related Issues (20)
- how to set width and height of jitter
- A modification suggestion for stat_compare_means
- ggsummarytable text angle option not available?
- change font in ggtexttable HOT 1
- The dot-dot notation (`..density..`) was deprecated in ggplot2 3.4.0.
- Add observation number in ggboxplot or similar functions?
- Error R2 with stat_cor function
- the order of category in x-axis is not correspond to figure label HOT 1
- ggbreak and ggpubr ggarrange do not play nicely together
- How to show the result of compare_means() in the stat_compare_means()
- Discrepancies between Wilcoxon test in `ggpubr` and `rstatix`? HOT 1
- Error in `*tmp*`[[1]] : subscript out of bounds
- Parsing of newline in facets HOT 1
- geom_pwc() with emmeans_test method
- Unnecessary legend problem when applying stat_summary
- Cannot fill symbols in geom_points with fill ="group"
- How to set transparency for barplot?
- BUG of geom_pwc(): the use of symnum.args leads to Error in `fortify()
- Manual p-value adjustment in geom_pwc
- ggboxplot warning The `fun.y` `fun.ymin` `fun.ymax` argument of `stat_summary()` is deprecated as of ggplot2 3.3.0.
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 ggpubr.