Created
January 13, 2023 01:24
-
-
Save timedreamer/a2e401a0b5409cc6d00562267f3218bb to your computer and use it in GitHub Desktop.
It's useful to plot many gene expression plots on a pdf. Each page has 3x3 or 4x4 plots.
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
# Thanks for the suggestion from Joseph Elsherbini. | |
library(tidyverse) | |
library(ggforce) | |
n_pages(p) # use this to get the number of pages to print | |
# then run a for loop to loop over pages | |
pdf("test.pdf") | |
for (i in 1:5) { | |
p <- ggplot(diamonds) + | |
geom_point(aes(carat, price), alpha = 0.1) + | |
facet_wrap_paginate(~ cut:clarity, ncol = 3, nrow = 3, page = i) | |
print(p) | |
} | |
dev.off() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment