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

ggsignif facetting issue - Missing significance labels in certain facets #138

Open
elenagmont opened this issue May 17, 2024 · 0 comments
Open

Comments

@elenagmont
Copy link

The significance label does not appear in facets where one group in the comparison list is missing (facet 'C' and 'E' in example).

Refer below (plot and code):

2024-05-17_example-boxplot-ggsignif

`data_example <- data.frame(matrix(ncol = 0, nrow = 2400))`

`data_example <- data_example %>%
 dplyr::mutate(
GROUP = rep(LETTERS[1:6], each = 100),
NUMERIC = sample(1:1000, 600, replace = TRUE), 
STATUS = case_when(GROUP == 'E' ~ rep(c('Good', 'Bad'), length.out = 600), GROUP == 'C' ~ rep(c('Neutral', 'Good'), length.out = 600),
TRUE ~ rep(c('Good', 'Bad', 'Neutral'), length.out = 600))
) `

`boxplot <- ggplot(data = data_example) + geom_boxplot(aes(x = STATUS, y = NUMERIC, fill = STATUS), color = "black", alpha = 0.7, position = position_dodge(width = 0.75)) + 
geom_point(aes(x = STATUS, y = NUMERIC, color = STATUS), position = position_jitterdodge(jitter.width = 0.2, dodge.width = 0.75),  size = 2, alpha = 0.2) + 
stat_signif(comparisons = list(c("Good", "Neutral"), c("Good", "Bad"), c("Neutral", "Bad")), aes(x = STATUS, y = NUMERIC), step_increase = 0.1, map_signif_level = TRUE) + 
facet_wrap(. ~ GROUP) + 
scale_x_discrete() + 
scale_y_log10(breaks = c(10^(-1:6)), minor_breaks = c(1:9 %o% 10^(-1:6)), labels = c('0.1', '1', "10", "100", "1'000", "10'000", "100'000", "1'000'000")) +
 labs(y = 'Numeric', x = 'Status') + 
theme_bw(base_size = 14) + 
theme(legend.position = "null")`

Thank you

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