knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.width = 7, fig.height = 5 )
library(ggplot2) library(ggsimplestats) theme_set(ggthemes::theme_few())
This vignette shows the options that are available for all functions to customize the results.
step.increase
changes the space between two brackets. Sometimes it is then necessary to expand the scales. This can e.g. be done with scale_y_continuous(expand = expansion(mult = c(0.05,0.15)))
ggplot(na.omit(palmerpenguins::penguins), aes(species, bill_length_mm, fill=species)) + geom_boxplot() + stat_tukeyHSD(vjust = -.2, step.increase = 0.2, format.fun = \(x) {glue::glue('parametric p-value\n{scales::pvalue(x)}')}) + facet_grid(~sex) + scale_y_continuous(expand = expansion(mult = c(0.05,0.15)))
colour
changes the colour of the bracket and the label.
ggplot(na.omit(palmerpenguins::penguins), aes(species, bill_length_mm, fill=species)) + geom_boxplot() + stat_tukeyHSD(vjust = -.2, step.increase = 0.08, format.fun = \(x) {glue::glue('p: {scales::pvalue(x)}')}, colour = 'darkred') + facet_grid(~sex) + scale_y_continuous(expand = expansion(mult = c(0.05,0.15)))
Use tick.length
to control the length of the ticks of the brackets.
ggplot(na.omit(palmerpenguins::penguins), aes(species, bill_length_mm, fill=species)) + geom_boxplot() + stat_tukeyHSD(vjust = -.2, step.increase = 0.12, format.fun = \(x) {glue::glue('p: {scales::pvalue(x)}')}, tick.length = 0.05) + facet_grid(~sex) + scale_y_continuous(expand = expansion(mult = c(0,0.15)))
Use 0
to remove them.
ggplot(na.omit(palmerpenguins::penguins), aes(species, bill_length_mm, fill=species)) + geom_boxplot() + stat_tukeyHSD(vjust = -.2, step.increase = 0.05, format.fun = \(x) {glue::glue('p: {scales::pvalue(x)}')}, tick.length = 0) + facet_grid(~sex) + scale_y_continuous(expand = expansion(mult = c(0,0.15)))
Use vjust
to control the the vertical adjustment of the text.
ggplot(na.omit(palmerpenguins::penguins), aes(species, bill_length_mm, fill=species)) + geom_boxplot() + stat_tukeyHSD(vjust = -1, step.increase = 0.12, format.fun = \(x) {glue::glue('p: {scales::pvalue(x)}')}) + facet_grid(~sex) + scale_y_continuous(expand = expansion(mult = c(0,0.15))) + ggtitle('Big gap') ggplot(na.omit(palmerpenguins::penguins), aes(species, bill_length_mm, fill=species)) + geom_boxplot() + stat_tukeyHSD(vjust = 1.2, step.increase = 0.12, format.fun = \(x) {glue::glue('p: {scales::pvalue(x)}')}) + facet_grid(~sex) + scale_y_continuous(expand = expansion(mult = c(0,0.15))) + ggtitle('Text below')
Use size
to control the the text size
ggplot(na.omit(palmerpenguins::penguins), aes(species, bill_length_mm, fill=species)) + geom_boxplot() + stat_tukeyHSD(size = 5, step.increase = 0.12, vjust = -.2, format.fun = \(x) {glue::glue('p: {scales::pvalue(x)}')}) + facet_grid(~sex) + scale_y_continuous(expand = expansion(mult = c(0,0.15))) + ggtitle('Tiny text') ggplot(na.omit(palmerpenguins::penguins), aes(species, bill_length_mm, fill=species)) + geom_boxplot() + stat_tukeyHSD(size = 20, step.increase = 0.12, vjust = -.2, format.fun = \(x) {glue::glue('{scales::pvalue(x)}')}) + facet_grid(~sex) + scale_y_continuous(expand = expansion(mult = c(0,0.15))) + ggtitle('Giant text')
Use hide.ns
to to remove non-significant p values (cutoff 0.05
). Default is TRUE
. Set hide.ns=FALSE
to show all p-values.
ggplot(na.omit(palmerpenguins::penguins), aes(species, bill_length_mm, fill=species)) + geom_boxplot() + stat_tukeyHSD(vjust = -.2, step.increase = 0.08, hide.ns = FALSE) + facet_grid(~sex) + scale_y_continuous(expand = expansion(mult = c(0,0.15))) + ggtitle('All p-values')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.