Skip to content
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

xmin/xmax from add_xy_position when x labels do not match between facets #203

Open
cpverschoor opened this issue Mar 20, 2024 · 0 comments

Comments

@cpverschoor
Copy link

cpverschoor commented Mar 20, 2024

Hi,

I am having trouble with the alignment of p-values and bars across facets when the x labels are not the same and scales are "free". Looks like add_xy_position is ignoring the "group" argument, although I might be misunderstanding the setup.

Below is a reproduceable example.

Many thanks!
Chris


library(ggplot2)
library(rstatix)
df <- data.frame(y=c(1,2,3,4,5,6,7,8,9,10),
                 x=c("a","a","b","b","c","c","d","d","e","e"),
                 group=c("X","X","X","X","Y","Y","Y","Y","Y","Y")
                 )
stat.test <- t_test(group_by(df,group),y~x)
  stat.test <- add_xy_position(stat.test,x="x",group="group",scales="free")

ggplot(df,aes(x=x,y=y))+
  ggplot2::geom_point()+
  facet_grid(~group,scales="free")+
  stat_pvalue_manual(stat.test,label="{p}")

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant