Skip to content

Instantly share code, notes, and snippets.

@jonjhkim
Created March 26, 2014 18:12
Show Gist options
  • Save jonjhkim/9789692 to your computer and use it in GitHub Desktop.
Save jonjhkim/9789692 to your computer and use it in GitHub Desktop.
ggplot-arrangeGrob
require("ggplot2")
require("gridExtra")
data <- data.frame(x = 1:10000, y = rnorm(n=10000, 0, 1))
p <- ggplot(data)
p1 <- p + geom_histogram(aes(x=y), binwidth=0.1, fill="deeppink4", colour="grey20", size=1.1)
p2 <- p + geom_point(aes(x=x, y=y), size=7, alpha=0.2, colour="deeppink4")
grobframe <- arrangeGrob(p1, p2, ncol=1, nrow=2,
main = textGrob("\nArrangeGrob Test", gp = gpar(fontsize=18, fontface="bold.italic", fontsize=18)),
sub = textGrob("*subtitle location*", x=0, hjust=-0.5, vjust=0.1, gp = gpar(fontface = "italic", fontsize = 15)))
print(grobframe)
ggsave(filename="~/test.png", plot=p3, width=18, height=10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment