Skip to content

Instantly share code, notes, and snippets.

@gireeshkbogu
Last active January 22, 2016 10:33
Show Gist options
  • Save gireeshkbogu/7e1bc7c3d92e26056cd5 to your computer and use it in GitHub Desktop.
Save gireeshkbogu/7e1bc7c3d92e26056cd5 to your computer and use it in GitHub Desktop.
library(ggplot2)
# Here I reduced the width of boxplots by 50%. because by default they look too big and ugly.
pp <- ggplot(mtcars, aes(factor(cyl), mpg)) + geom_boxplot(width = 0.5, aes(fill = factor(cyl))) + guides(fill=FALSE)
df1 <- data.frame(a = c(1, 1:3,3), b = c(39, 40, 40, 40, 39))
df2 <- data.frame(a = c(1, 1,2, 2), b = c(35, 36, 36, 35))
df3 <- data.frame(a = c(2, 2, 3, 3), b = c(24, 25, 25, 24))
pp + geom_line(data = df1, aes(x = a, y = b)) + annotate("text", x = 2, y = 42, label = "*", size = 8) +
geom_line(data = df2, aes(x = a, y = b)) + annotate("text", x = 1.5, y = 38, label = "**", size = 8) +
geom_line(data = df3, aes(x = a, y = b)) + annotate("text", x = 2.5, y = 27, label = "n.s.", size = 4)
@gireeshkbogu
Copy link
Author

p values

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment