Skip to content

Commit

Permalink
add parameter to control spacing between scalebars
Browse files Browse the repository at this point in the history
  • Loading branch information
whelena committed Oct 30, 2024
1 parent 41ce8c9 commit 52dbd68
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
6 changes: 4 additions & 2 deletions R/SRCGrob.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ SRCGrob <- function(
scale.bar = FALSE,
scale.bar.coords = c(0.5, 1),
scale.size.1 = NA,
scale.size.2 = NA
scale.size.2 = NA,
scale.padding = 1
) {

add.node.text <- !is.null(node.text);
Expand Down Expand Up @@ -118,7 +119,8 @@ SRCGrob <- function(
scale.bar = scale.bar,
scale.bar.coords = scale.bar.coords,
scale.size.1 = scale.size.1,
scale.size.2 = scale.size.2
scale.size.2 = scale.size.2,
scale.padding = scale.padding
);

out.tree <- gTree(
Expand Down
4 changes: 3 additions & 1 deletion R/make.clone.tree.grobs.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ make.clone.tree.grobs <- function(
scale.bar.coords,
scale.size.1,
scale.size.2,
scale.padding,
...
) {

Expand Down Expand Up @@ -173,7 +174,8 @@ make.clone.tree.grobs <- function(
scale.length = scale.lengths,
main.cex = axis.label.cex$y,
label.cex = axis.cex$y,
pos = scale.bar.coords
pos = scale.bar.coords,
padding = scale.padding
);
}

Expand Down
5 changes: 3 additions & 2 deletions R/scale.bar.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ add.scale.bar <- function(
yaxis1.label,
yaxis2.label,
pos,
padding,
...
) {

Expand Down Expand Up @@ -68,7 +69,7 @@ add.scale.bar <- function(
edge.width = most.common.value(clone.out$v$edge.width.2),
edge.type = most.common.value(clone.out$v$edge.type.2),
left.x = pos[1],
top.y = pos[2] + 0.1,
top.y = pos[2] + (padding / 10),
...
);
clone.out$grobs <- c(
Expand Down Expand Up @@ -153,7 +154,7 @@ create.scale.bar <- function(
tick.labels <- textGrob(
label = c(0, scale.length$label),
x = xat,
y = vp.y - tick.length * 2,
y = vp.y - tick.length * 2.5,
gp = gpar(
cex = label.cex
)
Expand Down

0 comments on commit 52dbd68

Please sign in to comment.