Description Usage Arguments Examples
A convenience function for displaying significance in ggplot2 plots
1 2 3 4 |
x_lo |
numeric, x position of left line ending |
x_hi |
numeric, x position of right line ending |
y_lo_left |
numeric, corresponding lower y position for |
y_lo_right |
numeric, corresponding lower y position for |
y_hi |
numeric, corresponding upper y-position for |
label |
character, text label to display, default is |
label_margin |
numeric, margin between |
text_size |
numeric, text size for label, default is |
line_size |
numeric, size of line elements, default is |
x_lo_lo |
numeric, if the left line ending ( |
x_lo_hi |
numeric, corresponding rightmost value for |
x_hi_lo |
numeric, if the right line ending ( |
x_hi_hi |
numeric, corresponding rightmost value for |
span_y |
numeric, y length of the bracket for
|
color |
character, color of label and line elements. |
family |
character, font family |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | library(ggplot2)
data <- data.frame(group = c("a", "b"), mean = c(20, 30), se = c(2.5, 3.0))
ggplot(data, aes(x = group, y = mean)) +
geom_bar(stat = "identity") +
geom_errorbar(aes(ymin = mean - se, ymax = mean + se), width = .5) +
plotsig(1, 2, 25, 35, 40)
data <- data.frame(factor1 = rep(letters[1:2], each = 2),
factor2 = rep(letters[3:4], times = 2),
mean = c(10, 12, 20, 35),
se = c(2.4, 3, 2.9, 3.1))
ggplot(data, aes(x = factor1, y = mean, fill = factor2)) +
geom_bar(stat = "identity", position = "dodge") +
geom_errorbar(aes(ymin = mean - se, ymax = mean + se), width = .5,
position = position_dodge(.9)) +
plotsig(1.775, 2.225, 25, 40, 45) +
plotsig(1, 2, 20, 50, 55, x_lo_lo = .55, x_lo_hi = 1.45, x_hi_lo = 1.55,
x_hi_hi = 2.45)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.