Skip to content

Commit

Permalink
Merge pull request #14 from karldw/master
Browse files Browse the repository at this point in the history
Allow combmatrix.panel.line.size = 0
  • Loading branch information
const-ae authored May 5, 2020
2 parents 9ee6898 + 9c6ce5a commit d379fb5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
30 changes: 12 additions & 18 deletions R/axis_combmatrix.R
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,19 @@ 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)
}

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)) +
Expand Down Expand Up @@ -303,18 +312,3 @@ element_render <- function (theme, element, ..., name = NULL) {
grob$name <- grobName(grob, paste(element, name, sep = "."))
grob
}















5 changes: 5 additions & 0 deletions tests/testthat/test-axis_combmatrix.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})

Expand Down

0 comments on commit d379fb5

Please sign in to comment.