From e7c291d4a201e696a98fb0570461f53045683994 Mon Sep 17 00:00:00 2001 From: karldw Date: Fri, 1 May 2020 11:16:11 -0700 Subject: [PATCH 1/2] Allow combmatrix.panel.line.size = 0 --- NEWS.md | 2 ++ R/axis_combmatrix.R | 32 ++++++++++++--------------- tests/testthat/test-axis_combmatrix.R | 5 +++++ 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/NEWS.md b/NEWS.md index 084365e..fa3c97d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,8 @@ # devel * Remove deprecated `as.tibble()` call (thanks to @abichat) +* Removed lines that remained in pdf output with `combmatrix.panel.line.size = 0` +(issue #12) # v0.2.1 diff --git a/R/axis_combmatrix.R b/R/axis_combmatrix.R index ff29396..60cecd3 100644 --- a/R/axis_combmatrix.R +++ b/R/axis_combmatrix.R @@ -254,10 +254,21 @@ make_combination_matrix_plot <- function(labels, labels_split, label_set, range, if(isTRUE(theme$combmatrix.panel.striped_background)){ plt <- plt + geom_rect(aes(fill= .data$index %% 2 == 0), ymin=df2$index-0.5, ymax=df2$index+0.5, xmin=0, xmax=1) } + if (!isTRUE(theme$combmatrix.panel.line.size == 0)) { + } + + plt <- plt + + geom_point(aes(color= .data$observed), size=theme$combmatrix.panel.point.size) + if (!isTRUE(theme$combmatrix.panel.line.size == 0)) { + # If combmatrix.panel.line.size is not a single number equal to 0, add the + # lines. (ifFALSE is available starting in v3.5) + plt <- plt + geom_line( + data=function(dat) dat[dat$observed, ,drop=FALSE], + aes(group = .data$labels), + size=theme$combmatrix.panel.line.size + ) + } plt + - geom_point(aes(color= .data$observed), size=theme$combmatrix.panel.point.size) + - geom_line(data=function(dat) dat[dat$observed, ,drop=FALSE], aes(group = .data$labels), - size=theme$combmatrix.panel.line.size) + ylab("") + xlab("") + scale_x_continuous(limits = c(0, 1), expand = c(0, 0)) + scale_y_discrete(breaks=label_set, labels=if(is.null(names(label_set))) waiver() else names(label_set)) + @@ -303,18 +314,3 @@ element_render <- function (theme, element, ..., name = NULL) { grob$name <- grobName(grob, paste(element, name, sep = ".")) grob } - - - - - - - - - - - - - - - diff --git a/tests/testthat/test-axis_combmatrix.R b/tests/testthat/test-axis_combmatrix.R index 3d589bf..d8ea632 100644 --- a/tests/testthat/test-axis_combmatrix.R +++ b/tests/testthat/test-axis_combmatrix.R @@ -49,6 +49,11 @@ test_that("Plotting works as expected", { ggplot(mtcars, aes(x=list_col)) + geom_bar() + scale_x_upset(n_intersections = 5, sets=c(paste0("gear: ", c(3,4,5)), paste0("cyl: ", c(4,6,8,9)))) + + ggplot(mtcars, aes(x=list_col)) + + geom_bar() + + scale_x_upset(n_intersections = 5) + + theme_combmatrix(combmatrix.panel.line.size = 0) }) }) From 9c6ce5a9b08b1fb22fb736dd8a1654077cc55650 Mon Sep 17 00:00:00 2001 From: karldw Date: Mon, 4 May 2020 11:04:02 -0700 Subject: [PATCH 2/2] Remove empty if-statement --- R/axis_combmatrix.R | 2 -- 1 file changed, 2 deletions(-) diff --git a/R/axis_combmatrix.R b/R/axis_combmatrix.R index 60cecd3..d436685 100644 --- a/R/axis_combmatrix.R +++ b/R/axis_combmatrix.R @@ -254,8 +254,6 @@ make_combination_matrix_plot <- function(labels, labels_split, label_set, range, if(isTRUE(theme$combmatrix.panel.striped_background)){ plt <- plt + geom_rect(aes(fill= .data$index %% 2 == 0), ymin=df2$index-0.5, ymax=df2$index+0.5, xmin=0, xmax=1) } - if (!isTRUE(theme$combmatrix.panel.line.size == 0)) { - } plt <- plt + geom_point(aes(color= .data$observed), size=theme$combmatrix.panel.point.size)