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

adding scale_y_log10 changes y-axis to a weird range #18

Open
rxhu opened this issue Jun 2, 2022 · 1 comment
Open

adding scale_y_log10 changes y-axis to a weird range #18

rxhu opened this issue Jun 2, 2022 · 1 comment

Comments

@rxhu
Copy link

rxhu commented Jun 2, 2022

add_pvalue function affects scale_y_log10's behavior, e.g.

tg <- ToothGrowth
tg$dose <- as.factor(tg$dose)
tg$group <- factor(rep(c("grp1", "grp2"), 30))
two.means <- tibble::tribble(
~group1, ~group2, ~p, ~y.position,
"OJ", "VC", 0.0606, 36)

Without scale_y_log10, add_pvalue works as expected
ggplot(tg, aes(x = supp, y = len)) + geom_boxplot() + add_pvalue(two.means)

With scale_y_log10, y-axis become extremely large and original plots are squeezed to the bottom
ggplot(tg, aes(x = supp, y = len)) + geom_boxplot() + add_pvalue(two.means) + scale_y_log10()

csdaw added a commit that referenced this issue Jun 27, 2022
Attempt to address #18 without breaking
anything.
@csdaw
Copy link
Owner

csdaw commented Jun 27, 2022

Thanks for the reproducible example! It seems to be a bug in the bracket y position calculation. Try installing from Github and it should fix the issue.

library(ggplot2)
library(ggprism)

tg <- ToothGrowth
tg$dose <- as.factor(tg$dose)
tg$group <- factor(rep(c("grp1", "grp2"), 30))
two.means <- tibble::tribble(
  ~group1, ~group2, ~p, ~y.position,
  "OJ", "VC", 0.0606, 36
)

ggplot(tg, aes(x = supp, y = len)) + geom_boxplot() + add_pvalue(two.means)

ggplot(tg, aes(x = supp, y = len)) + geom_boxplot() + scale_y_log10() + add_pvalue(two.means)

Created on 2022-06-27 by the reprex package (v2.0.1)

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

2 participants