diff --git a/R/make.clone.tree.grobs.R b/R/make.clone.tree.grobs.R index 628777a..d81060b 100644 --- a/R/make.clone.tree.grobs.R +++ b/R/make.clone.tree.grobs.R @@ -1,4 +1,3 @@ - make.clone.tree.grobs <- function( ccf.df, tree, diff --git a/R/set.up.plot.area.R b/R/set.up.plot.area.R index 0e00707..b24eddd 100644 --- a/R/set.up.plot.area.R +++ b/R/set.up.plot.area.R @@ -15,15 +15,17 @@ calculate.main.plot.size <- function( node.radius ) { - ymax <- max(clone.out$v$len) + clone.out$v$y[1]; - height <- (ymax) * scale1; + padding <- 2 * node.radius / scale1; + ymax <- clone.out$v$y[which.max(abs(clone.out$v$y))]; + ymax <- ymax + (- sign(ymax) * padding); + height <- ymax * scale1; if (is.null(min.width)) { xmax <- wid; width <- wid * scale1 + 4 * node.radius; xlims <- c( - -(xmax / 2) - (2 * node.radius / scale1), - xmax / 2 + 2 * node.radius / scale1 + -(xmax / 2) - padding, + xmax / 2 + padding ); } else { xmin <- min(c(clone.out$v$x)); @@ -37,8 +39,8 @@ calculate.main.plot.size <- function( xmin <- xmin - 0.5 * diff / scale1 xmax <- xmax + 0.5 * diff / scale1; xlims <- c( - xmin - (2 * node.radius / scale1), - xmax + 2 * node.radius / scale1 + xmin - padding, + xmax + padding ); width <- (max(xlims) - min(xlims)) * scale1; @@ -52,9 +54,7 @@ calculate.main.plot.size <- function( clone.out$vp <- make.plot.viewport( clone.out, - clip = if (clone.out$no.ccf) 'off' else 'on', - just = c('centre', 'top'), - y = 0.9 + clip = if (clone.out$no.ccf) 'off' else 'on' ); } @@ -247,6 +247,11 @@ add.yaxis <- function( y.ticks.at <- ylabels / conversion.factor; + if (length(ylabels) == 0 || length(y.ticks.at) == 0) { + warning('No y-axis ticks to draw. Skipping axis rendering.'); + return(ymax); + } + yaxis1 <- yaxisGrob( name = 'axis.content', at = y.ticks.at, @@ -344,7 +349,8 @@ add.main <- function( size.units = 'npc' ) { - y.pos <- unit(1.08,'npc'); + # y.pos <- unit(1.08,'npc'); + y.pos <- unit(0.5,'npc'); if (!is.null(main.y)) { pushViewport(clone.out$vp); diff --git a/tests/testthat/data/branching.dendrogram.plots.Rda b/tests/testthat/data/branching.dendrogram.plots.Rda index e15feca..38f25e0 100644 Binary files a/tests/testthat/data/branching.dendrogram.plots.Rda and b/tests/testthat/data/branching.dendrogram.plots.Rda differ diff --git a/tests/testthat/data/branching.fixed.plots.Rda b/tests/testthat/data/branching.fixed.plots.Rda index aa8146c..8774cf5 100644 Binary files a/tests/testthat/data/branching.fixed.plots.Rda and b/tests/testthat/data/branching.fixed.plots.Rda differ diff --git a/tests/testthat/data/branching.radial.plots.Rda b/tests/testthat/data/branching.radial.plots.Rda index 4112333..1addead 100644 Binary files a/tests/testthat/data/branching.radial.plots.Rda and b/tests/testthat/data/branching.radial.plots.Rda differ diff --git a/tests/testthat/data/linear.plots.Rda b/tests/testthat/data/linear.plots.Rda index 33ca95e..a1ec3d0 100644 Binary files a/tests/testthat/data/linear.plots.Rda and b/tests/testthat/data/linear.plots.Rda differ