Skip to content

Commit

Permalink
if no names, default no breaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Yunuuuu committed Jul 16, 2024
1 parent f8d5876 commit 0858911
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion R/anno-initialize.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ anno_initialize.anno <- function(object, plot, object_name) {
# if waiver, will inherit from the heatmap
labels_nudge <- set_nudge(
slot(object, "labels_nudge"),
nrow(data), axis
nrow(data), labels,
axis
) %|w|% .subset2(
slot(plot, "params"),
paste0(to_coord_axis(position), "labels_nudge")
Expand Down
8 changes: 5 additions & 3 deletions R/ggheat.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ ggheat.matrix <- function(data, mapping = NULL,
environment = parent.frame()) {
assert_bool(filling)
xlabels <- set_labels(xlabels, "column", colnames(data), ncol(data))
xlabels_nudge <- set_nudge(xlabels_nudge, ncol(data))
xlabels_nudge <- set_nudge(xlabels_nudge, ncol(data), xlabels, "column")
ylabels <- set_labels(ylabels, "row", rownames(data), nrow(data))
ylabels_nudge <- set_nudge(ylabels_nudge, ncol(data))
ylabels_nudge <- set_nudge(ylabels_nudge, ncol(data), ylabels, "row")
mapping <- mapping %||% aes(.data$.x, .data$.y)
heatmap <- ggplot2::ggplot(mapping = mapping)
if (ncol(data) > 10L) {
Expand Down Expand Up @@ -82,9 +82,11 @@ ggheat.matrix <- function(data, mapping = NULL,
)
}

set_nudge <- function(nudge, n, axis,
set_nudge <- function(nudge, n, names, axis,
arg = rlang::caller_arg(nudge),
call = caller_call()) {
# if no names, default to
if (is.waiver(nudge) && is.null(names)) return(NULL) # styler: off
if (is.numeric(nudge)) {
if (!is_scalar(nudge) && length(nudge) != n) {
cli::cli_abort(paste(
Expand Down

0 comments on commit 0858911

Please sign in to comment.