Comments (1)
Hi there,
The easiest way to do this is manually (although there should be a way using rstatix::add_xy_position()
directly but I can't immediately figure out how).
library(ggplot2)
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(ggprism)
# manually dodge xmin and xmax of bracket lines
df_p_val <- ToothGrowth %>%
rstatix::group_by(supp) %>%
rstatix::t_test(len ~ dose) %>%
rstatix::add_xy_position() %>%
mutate(xmin = xmin + rep(c(-0.2, 0.2), each = 3),
xmax = xmax + rep(c(-0.2, 0.2), each = 3))
p <- ggplot(ToothGrowth, aes(x = factor(dose), y = len)) +
geom_boxplot(aes(fill = supp)) +
theme_prism()
# need to specify xmin and xmax columns here
p + add_pvalue(df_p_val,
xmin = 'xmin',
xmax = 'xmax',
label = "p = {p.adj}",
colour = "supp",
fontface = "bold",
step.group.by = "supp",
step.increase = 0.1,
tip.length = 0,
bracket.colour = "black",
show.legend = FALSE)
Created on 2022-11-02 with reprex v2.0.2
from ggprism.
Related Issues (20)
- Integrate `latex2exp::TeX` into `add_pvalue`? HOT 4
- step.increase in add_y_position() is bad HOT 1
- Cant hide legend HOT 1
- adding scale_y_log10 changes y-axis to a weird range HOT 1
- Planned features
- Issues with next version of ggplot2 HOT 2
- Release ggprism 1.0.4
- Unable to display legend title HOT 2
- The `legend.text.align` theme element is not defined in the element hierarchy. HOT 6
- theme_prism() not working with ggplot2 HOT 2
- Release ggprism 1.0.5
- adding new themes HOT 1
- An "i" in the label string is forced to be capitalized.
- Error on add_pvalue with geom_jitter() aes HOT 2
- Release ggprism 1.0.1 HOT 1
- Release ggprism 1.0.2
- hide.NS option for add_pvalue function HOT 4
- Issue with the next release of ggplot2 HOT 1
- Release ggprism 1.0.3
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 ggprism.