Skip to content

Commit

Permalink
Fix plot labels
Browse files Browse the repository at this point in the history
  • Loading branch information
nfrerebeau committed Aug 31, 2024
1 parent d12e307 commit 09480cc
Show file tree
Hide file tree
Showing 11 changed files with 120 additions and 147 deletions.
2 changes: 1 addition & 1 deletion R/plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ plot.LogRatio <- function(x, ..., groups = get_groups(x),
}

xlim <- range(dens_x, na.rm = TRUE)
ylabs <- ylab %||% colnames(z) %||% paste0("P", p_seq)
ylabs <- ylab %||% labels(z) %||% paste0("z", p_seq)
for (j in p_seq) {
tmp_x <- dens_x[, j, , drop = FALSE]
tmp_y <- dens_y[, j, , drop = FALSE]
Expand Down
4 changes: 2 additions & 2 deletions R/transform_alr.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ setMethod(
.ALR(
alr,
parts = parts,
ratio = colnames(alr),
ratio = paste(parts[-D], parts[D], sep = "/"),
order = order(ordering),
base = base,
weights = w,
Expand Down Expand Up @@ -76,7 +76,7 @@ setMethod(
.ALR(
alr,
parts = parts,
ratio = colnames(alr),
ratio = paste(parts[-D], parts[D], sep = "/"),
order = order(ordering),
base = base,
weights = w,
Expand Down
2 changes: 1 addition & 1 deletion R/transform_ilr.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ setMethod(
ratio <- vapply(
X = seq_parts,
FUN = function(i, k) {
paste(paste0(k[seq_len(i)], collapse = "-"), k[i + 1], sep = "_")
sprintf("(%s)/%s", paste0(k[seq_len(i)], collapse = ","), k[i + 1])
},
FUN.VALUE = character(1),
k = parts
Expand Down
2 changes: 1 addition & 1 deletion R/transform_lr.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ setMethod(

w <- unlist(utils::combn(weights, 2, FUN = function(x) Reduce(`*`, x),
simplify = FALSE))
r <- unlist(utils::combn(parts, 2, FUN = paste, collapse = "_",
r <- unlist(utils::combn(parts, 2, FUN = paste, collapse = "/",
simplify = FALSE))

jj <- utils::combn(seq_len(J), 2, simplify = FALSE)
Expand Down
2 changes: 1 addition & 1 deletion R/transform_plr.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ setMethod(
X = seq_len(J - 1),
FUN = function(i, parts) {
j <- length(parts)
sprintf("%s_%s", parts[1], paste0(parts[(i+1):j], collapse = "-"))
sprintf("%s/(%s)", parts[1], paste0(parts[(i+1):j], collapse = ","))
},
FUN.VALUE = character(1),
parts = parts
Expand Down
Binary file modified inst/tinytest/_snaps/transform_alr.rds
Binary file not shown.
Binary file modified inst/tinytest/_snaps/transform_ilr.rds
Binary file not shown.
Binary file modified inst/tinytest/_snaps/transform_lr.rds
Binary file not shown.
Binary file modified inst/tinytest/_snaps/transform_plr.rds
Binary file not shown.
251 changes: 112 additions & 139 deletions inst/tinytest/_tinysnapshot/plot_ratio.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions inst/tinytest/test_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ if (at_home()) {
# Density ====================================================================
# See argument old.coords of density().
if (getRversion() >= "4.4.0") {
clr <- transform_clr(coda)
ilr <- transform_ilr(coda)

plot_ratio <- function() plot(clr, groups = rep(1:5, 5))
plot_ratio <- function() plot(ilr, groups = rep(1:5, 5), ncol = 2)
expect_snapshot_plot(plot_ratio, "plot_ratio")
}
}

0 comments on commit 09480cc

Please sign in to comment.