Skip to content

Instantly share code, notes, and snippets.

View chansigit's full-sized avatar
🏔️
working

Sijie Chen chansigit

🏔️
working
  • Stanford University
  • CA
  • 16:15 (UTC -07:00)
View GitHub Profile
@chansigit
chansigit / save_pheatmap_pdf.R
Created October 10, 2022 10:23 — forked from timedreamer/save_pheatmap_pdf.R
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)