Last active
August 29, 2015 14:27
-
-
Save joelcarlson/a07d6c4afacbcfc28324 to your computer and use it in GitHub Desktop.
Template for creating a strip chart with the dots connected to each other. Data should be in melted form (see reshape2::melt() ). Going to need to edit and play around if you need to connect more than two points. I probably should just make this a function, but in lieu of that, here is a template!
This file contains hidden or 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
ggplot(data, aes(x=factor, y=value, col=variable, alpha=0.75)) + | |
geom_point() + | |
geom_segment(data=YOURDATA, aes(x = 1, y = COLUMNOFYVALS, xend = 2, yend = COLUMNOFOTHERYVALS, col=variable, alpha=0.75)) + | |
ggtitle("Whatever you like") + | |
labs(y="asdasd", x="asdasd") + | |
theme_fivethirtyeight() + | |
scale_alpha(guide = "none") + | |
theme(#legend.justification=c(1,1), legend.position=c(1,1),, #Make background white, | |
legend.title=element_blank(), | |
legend.background = element_rect(fill="white"), legend.key = element_rect(fill="white"), #Make legend background filled | |
panel.background = element_blank(), plot.background = element_blank(), | |
axis.title=element_text(), axis.title.y=element_text(angle = 90, vjust=1.5), axis.title.x=element_blank()) | |
ggsave(file = paste0(SOMEDIR, "/Figures/stripchart.png"), | |
scale = 1, width = 10, height = 12, units = c("cm"), dpi = 300, limitsize = TRUE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment