Last active
January 22, 2016 10:33
-
-
Save gireeshkbogu/7e1bc7c3d92e26056cd5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
Author
gireeshkbogu
commented
Jan 22, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment