Skip to content

Commit

Permalink
Allow to add global aes when plotting visualisation_recipe() (#383)
Browse files Browse the repository at this point in the history
* Allow to add global aes when plotting `visualosation_recipe()`

* version
  • Loading branch information
strengejacke authored Jan 31, 2025
1 parent f1bd98d commit 9fe3cc1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: see
Title: Model Visualisation Toolbox for 'easystats' and 'ggplot2'
Version: 0.10.0
Version: 0.10.0.2
Authors@R:
c(person(given = "Daniel",
family = "Lüdecke",
Expand Down
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 9fe3cc1

Please sign in to comment.