Skip to content

Commit 3920548

Browse files
committed
Fix pheatmap double-rendering by overriding print.pheatmap
pheatmap's print method omits grid.newpage(), causing the heatmap to draw on top of the previous plot when mixed with ggplot in the same knitr chunk or graphics device. Add a print.pheatmap S3 method in prolfqua that calls grid.newpage() before grid.draw().
1 parent 76b4a4a commit 3920548

3 files changed

Lines changed: 34 additions & 0 deletions

File tree

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Generated by roxygen2: do not edit by hand
22

3+
S3method(print,pheatmap)
34
export(.summarise_missing_contrasts)
45
export(AnalysisConfiguration)
56
export(Benchmark)

R/tidyMS_plotting.R

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
#' Print method for pheatmap objects
2+
#'
3+
#' Fixes pheatmap's print method which omits \code{grid.newpage()},
4+
#' causing the heatmap to draw on top of the previous plot when
5+
#' multiple plots are produced in the same knitr chunk or graphics device.
6+
#'
7+
#' @param x a pheatmap object
8+
#' @param ... ignored
9+
#' @export
10+
#' @method print pheatmap
11+
print.pheatmap <- function(x, ...) {
12+
grid::grid.newpage()
13+
grid::grid.draw(x$gtable)
14+
}
15+
116
#' visualize intensity distributions
217
#' @param pdata data.frame
318
#' @param config AnalysisConfiguration

man/print.pheatmap.Rd

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)