Skip to content

Commit

Permalink
Allow to add global aes when plotting visualosation_recipe()
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Jan 31, 2025
1 parent f1bd98d commit 2761dff
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions R/plot.visualisation_recipe.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,16 @@ plot.see_visualisation_recipe <- function(x, ...) {
}
suppressWarnings(ggraph::ggraph(attributes(x)$data, layout = attributes(x)$layout) + geoms_from_list(x))
} else {
suppressWarnings(ggplot2::ggplot(data = attributes(x)$data) +
geoms_from_list(x, ...))
global_aes <- attributes(x)$global_aes
if (!is.null(global_aes) && length(global_aes)) {
global_aes <- do.call(ggplot2::aes, args = lapply(global_aes, .str_to_sym))
}
suppressWarnings(
do.call(
ggplot2::ggplot,
insight::compact_list(list(data = attributes(x)$data, mapping = global_aes))
) + geoms_from_list(x, ...)
)
}
}

Expand Down

0 comments on commit 2761dff

Please sign in to comment.