Skip to content

Instantly share code, notes, and snippets.

@timedreamer
Created January 7, 2021 22:18
Show Gist options
  • Save timedreamer/eee213cca917bdf35fb0b24f8cb6932d to your computer and use it in GitHub Desktop.
Save timedreamer/eee213cca917bdf35fb0b24f8cb6932d 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