Skip to content

Instantly share code, notes, and snippets.

@chansigit
Forked from timedreamer/save_pheatmap_pdf.R
Created October 10, 2022 10:23
Show Gist options
  • Save chansigit/e493067eaf0eecf4014fbc37f1552277 to your computer and use it in GitHub Desktop.
Save chansigit/e493067eaf0eecf4014fbc37f1552277 to your computer and use it in GitHub Desktop.
Save pheatmap figure into pdf
# An R function to save pheatmap figure into pdf
# This was copied from Stackflow: https://stackoverflow.com/questions/43051525/how-to-draw-pheatmap-plot-to-screen-and-also-save-to-file
save_pheatmap_pdf <- function(x, filename, width=7, height=7) {
stopifnot(!missing(x))
stopifnot(!missing(filename))
pdf(filename, width=width, height=height)
grid::grid.newpage()
grid::grid.draw(x$gtable)
dev.off()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment