feat: added option to choose color palettes for all available plots. this includes a custom function to generate colors from several palettes as well as a select function to include color previews.

This commit is contained in:
Andreas Gammelgaard Damsbo 2026-03-24 12:04:54 +01:00
commit 6c850847b7
No known key found for this signature in database
21 changed files with 1110 additions and 251 deletions

View file

@ -1,4 +1,4 @@
#' Beatiful violin plot
#' Beautiful violin plot
#'
#' @returns ggplot2 object
#' @export
@ -6,8 +6,9 @@
#' @name data-plots
#'
#' @examples
#' mtcars |> plot_violin(pri = "mpg", sec = "cyl", ter = "gear")
plot_violin <- function(data, pri, sec, ter = NULL) {
#' mtcars |> plot_violin(pri = "mpg", sec = "cyl")
#' mtcars |> plot_violin(pri = "mpg", sec = "cyl", ter = "gear", color.palette="Blues")
plot_violin <- function(data, pri, sec, ter = NULL, color.palette="viridis") {
if (!is.null(ter)) {
ds <- split(data, data[ter])
} else {
@ -23,7 +24,8 @@ plot_violin <- function(data, pri, sec, ter = NULL) {
response = pri,
xtitle = get_label(data, var = sec),
ytitle = get_label(data, var = pri)
)
)+
scale_fill_generate(palette=color.palette)
})
wrap_plot_list(out, title = glue::glue(i18n$t("Grouped by {get_label(data,ter)}")))