Skip to content

Commit

Permalink
Label leaves
Browse files Browse the repository at this point in the history
  • Loading branch information
ms609 committed Sep 7, 2023
1 parent 5535cfa commit 768dbd0
Show file tree
Hide file tree
Showing 4 changed files with 199 additions and 7 deletions.
4 changes: 2 additions & 2 deletions R/plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
#' @keywords internal
#' @export
TreeDistPlot <- function(tr, title = NULL, bold = NULL, leaveRoom = FALSE,
prune = integer(0), graft = integer(0),
edge.color = "black", edge.width = NULL, ...) {
prune = integer(0), graft = integer(0),
edge.color = "black", edge.width = NULL, ...) {

nEdge <- dim(tr$edge)[1]
if (is.null(tr$edge.length)) {
Expand Down
98 changes: 98 additions & 0 deletions tests/testthat/_snaps/plot/vm-one-rooted.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
95 changes: 95 additions & 0 deletions tests/testthat/_snaps/plot/vm-unrooted.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 4 additions & 5 deletions tests/testthat/test-plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -141,20 +141,19 @@ test_that("VisualizeMatching() handles unrooted trees", {
skip_if_not_installed("graphics", "4.3")
skip_if_not_installed("vdiffr", "1.0")


vdiffr::expect_doppelganger("VM unrooted", function() {
par(mfrow = c(2, 2), mar = rep(0.1, 4), cex = 1.5)
tree1 <- UnrootTree(BalancedTree(5))
tree2 <- UnrootTree(PectinateTree(5))
tree1 <- UnrootTree(BalancedTree(1:5))
tree2 <- UnrootTree(PectinateTree(1:5))
VisualizeMatching(RobinsonFouldsMatching, tree1, tree2,
setPar = FALSE,
Plot = TreeDistPlot)
})

vdiffr::expect_doppelganger("VM one rooted", function() {
par(mfrow = c(2, 2), mar = rep(0.1, 4), cex = 1.5)
tree1 <- UnrootTree(BalancedTree(5))
tree2 <- PectinateTree(5)
tree1 <- UnrootTree(BalancedTree(1:5))
tree2 <- PectinateTree(1:5)
VisualizeMatching(RobinsonFouldsMatching, tree1, tree2,
setPar = FALSE,
Plot = TreeDistPlot)
Expand Down

0 comments on commit 768dbd0

Please sign in to comment.