const-ae / ggsignif

Easily add significance brackets to your ggplots
https://const-ae.github.io/ggsignif/
GNU General Public License v3.0
593 stars 43 forks source link

feature request: allow user given text as 'p value' #29

Closed andreasleha closed 7 years ago

andreasleha commented 7 years ago

To give full control to the user, it would be nice, if there was the possibility to pass a character vector to be plotted as the 'p value'. I am thinking of something along the lines

geom_signif(comparisons = list(c("A", "B"), c("A", "C"), c("A", "D")),
            pvalues     = c("< 0.02", "not computable", "****"))

This is just a silly example, of course.

andreasleha commented 7 years ago

A hacky 'solution' is to use a custom test function which matches the passed vectors x and y and returns the corresponding text as p.value of a list. But this is really just an ugly hack.

const-ae commented 7 years ago

Hi, you can already define the text using the annotations parameter:

ggplot(mpg, aes(class, hwy)) +
    geom_boxplot() +
    geom_signif(comparisons = list(c("compact", "midsize"), c("minivan", "suv")),
                annotations = c("Nearby", "Far Apart"),
                map_signif_level = TRUE, textsize=6) +
    ylim(NA, 48)

image

Or did misunderstand your question?

andreasleha commented 7 years ago

No you did not mis-understand the question. I did not read the documentation carefully. annotations is exactly what I was proposing.