From 411318c1902838cc7b8c1ffd4666e54eb14ffcc3 Mon Sep 17 00:00:00 2001 From: davidhodge931 Date: Mon, 2 Dec 2024 09:49:24 +1300 Subject: [PATCH] Add geom_lineribbon defaults to weave_geom_defaults --- R/weave.R | 3 ++ vignettes/articles/2_demo_dark.Rmd | 1 + vignettes/articles/4_extensions.Rmd | 45 ++++++++++++----------------- 3 files changed, 23 insertions(+), 26 deletions(-) diff --git a/R/weave.R b/R/weave.R index c4791a528..c893474aa 100644 --- a/R/weave.R +++ b/R/weave.R @@ -93,6 +93,9 @@ weave_geom_defaults <- function( #text ggplot2::update_geom_defaults("text", ggplot2::aes(colour = !!text_colour, size = !!text_size, family = !!text_family)) ggplot2::update_geom_defaults("label", ggplot2::aes(colour = !!text_colour, fill = !!text_colour, alpha = 0.05, size = !!text_size, family = !!text_family)) + + #extras + ggplot2::update_geom_defaults("lineribbon", ggplot2::aes(colour = !!colour, fill = !!fill, linewidth = 0.66)) } #' Set a discrete colour and fill palettes diff --git a/vignettes/articles/2_demo_dark.Rmd b/vignettes/articles/2_demo_dark.Rmd index 5ddb38550..2290573f0 100644 --- a/vignettes/articles/2_demo_dark.Rmd +++ b/vignettes/articles/2_demo_dark.Rmd @@ -163,6 +163,7 @@ penguins2 |> gg_density( x = flipper_length_mm, col = species, + col_palette = c(teal, orange, pink), blend = "multiply", mode = dark_mode_t(), ) diff --git a/vignettes/articles/4_extensions.Rmd b/vignettes/articles/4_extensions.Rmd index f8c65c8bc..829fcac41 100644 --- a/vignettes/articles/4_extensions.Rmd +++ b/vignettes/articles/4_extensions.Rmd @@ -278,10 +278,27 @@ ggridges::Catalan_elections |> ### ggdist -The ggdist package enables the visualisation of uncertainty. +The ggdist package supports the visualisation of uncertainty. ```{r} library(ggdist) +geom_lineribbon() + +data.frame(year = 1875:1972, level = as.vector(LakeHuron)) |> + mutate(level_min = level - 1, level_max = level + 1) |> + gg_blanket( + geom = "lineribbon", + x = year, + y = level, + ymin = level_min, + ymax = level_max, + x_labels = \(x) x, + y_label = "Level", + blend = "multiply", + ) +``` + +```{r} library(distributional) geom_slabinterval() @@ -311,29 +328,6 @@ data.frame( theme(legend.position = "none") ``` -```{r} -geom_lineribbon() - -set.seed(123) - -tibble(x = 1:10) |> - group_by(across(everything())) |> - do(tibble(y = rnorm(100, .$x))) |> - median_qi(.width = c(0.5, 0.8, 0.95)) |> - mutate(.width = factor(.width)) |> - gg_blanket( - geom = "lineribbon", - x = x, - y = y, - ymin = .lower, - ymax = .upper, - col = .width, - colour = viridis::mako(n = 9)[c(1)], - col_legend_rev = TRUE, - col_palette = viridis::mako(n = 9)[c(4,6,9)], - ) -``` - ### ggdensity The ggdensity package provides visualizations of density estimates. @@ -355,8 +349,7 @@ data.frame( x = x, y = y, y_symmetric = FALSE, - ) + - guides(colour = FALSE, fill = FALSE) + ) ``` ```{r}