Skip to content

Commit

Permalink
Fix x-axis rendering bug
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-knight committed Jan 7, 2025
1 parent c02b2e8 commit 190d840
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 58 deletions.
29 changes: 14 additions & 15 deletions R/make.clone.tree.grobs.R
Original file line number Diff line number Diff line change
Expand Up @@ -140,21 +140,20 @@ make.clone.tree.grobs <- function(
add.normal(clone.out,node.radius,label.cex, normal.cex)
}

if (yaxis.position != 'none' & scale.bar == FALSE) {
add.axes(
clone.out,
yaxis.position,
scale1 = scale1,
scale2 = scale2,
yat = yat,
axis.label.cex = axis.label.cex,
axis.cex = axis.cex,
no.ccf = no.ccf,
xaxis.label = xaxis.label,
yaxis1.label = yaxis1.label,
yaxis2.label = yaxis2.label
);
}
add.axes(
clone.out,
yaxis.position,
scale1 = scale1,
scale2 = scale2,
scale.bar = scale.bar,
yat = yat,
axis.label.cex = axis.label.cex,
axis.cex = axis.cex,
no.ccf = no.ccf,
xaxis.label = xaxis.label,
yaxis1.label = yaxis1.label,
yaxis2.label = yaxis2.label
);

if (scale.bar) {
scale.lengths <- prep.scale.length(
Expand Down
89 changes: 46 additions & 43 deletions R/set.up.plot.area.R
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,11 @@ add.axis.label <- function(axisGrob, axis.label, axis.position, axis.label.cex,

add.axes <- function(
clone.out,
yat,
scale1,
scale2 = NULL,
scale.bar = FALSE,
yaxis.position = 'left',
yat,
xaxis.label = 'CCF',
yaxis1.label = 'PGA',
yaxis2.label = NULL,
Expand All @@ -176,48 +177,50 @@ add.axes <- function(
);
}

ylabels1 <- unlist(yat[1]);
ylabels2 <- unlist(yat[2]);

if (yaxis.position == 'both') {
if (is.null(yaxis2.label)) {
warning('Missing second y-axis label');
yaxis2.label <- '';
}

conversion.factor <- scale1 / scale2

ymax1 <- add.yaxis(
clone.out,
yaxis.position = 'left',
axis1.label = yaxis1.label,
no.ccf = no.ccf,
axis.label.cex = axis.label.cex[['y']],
axis.cex = axis.cex[['y']],
ylabels = ylabels1
);

add.yaxis(
clone.out,
yaxis.position = 'right',
conversion.factor = conversion.factor,
axis1.label = yaxis2.label,
no.ccf = no.ccf,
axis.label.cex = axis.label.cex[['y']],
axis.cex = axis.cex[['y']],
ylabels = ylabels2
);
} else {
add.yaxis(
clone.out,
yaxis.position = yaxis.position,
axis1.label = yaxis1.label,
no.ccf = no.ccf,
axis.label.cex = axis.label.cex[['y']],
axis.cex = axis.cex[['y']],
ylabels = ylabels1
);
}
if (yaxis.position != 'none' & scale.bar == FALSE) {
ylabels1 <- unlist(yat[1]);
ylabels2 <- unlist(yat[2]);

if (yaxis.position == 'both') {
if (is.null(yaxis2.label)) {
warning('Missing second y-axis label');
yaxis2.label <- '';
}

conversion.factor <- scale1 / scale2

ymax1 <- add.yaxis(
clone.out,
yaxis.position = 'left',
axis1.label = yaxis1.label,
no.ccf = no.ccf,
axis.label.cex = axis.label.cex[['y']],
axis.cex = axis.cex[['y']],
ylabels = ylabels1
);

add.yaxis(
clone.out,
yaxis.position = 'right',
conversion.factor = conversion.factor,
axis1.label = yaxis2.label,
no.ccf = no.ccf,
axis.label.cex = axis.label.cex[['y']],
axis.cex = axis.cex[['y']],
ylabels = ylabels2
);
} else {
add.yaxis(
clone.out,
yaxis.position = yaxis.position,
axis1.label = yaxis1.label,
no.ccf = no.ccf,
axis.label.cex = axis.label.cex[['y']],
axis.cex = axis.cex[['y']],
ylabels = ylabels1
);
}
}
}

add.yaxis <- function(
Expand Down

0 comments on commit 190d840

Please sign in to comment.