diff --git a/DESCRIPTION b/DESCRIPTION index a11bc718a..744e67f4b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: ggblanket Title: Simplify 'ggplot2' Visualisation -Version: 5.2.0 +Version: 5.2.0900 Authors@R: c( person("David", "Hodge", email = "davidhodge931@gmail.com", role = c("aut", "cre", "cph"), comment = c(ORCID = "0000-0002-3868-7501")), diff --git a/NEWS.md b/NEWS.md index badaf8054..233f27459 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,6 @@ # ggblanket 5.2.0 -* Updated colours: `#357BA2` or `mako[9](5)` where no col aesthetic, `guardian` where discrete and 4 or less colours, scales:hue_pal for 5 or more colours, `viridis::mako` reversed for continuous, and `"grey"` for NA. +* Updated colours: `#357BA2` or `mako[9](5)` where no col aesthetic, `guardian` where discrete and 4 or less colours, scales:hue_pal for 5 or more colours, `viridis::mako` reversed for continuous, and `"grey"` for NA. * Breaking: removed all `pal_*` functions. * Removed some unnecessary messages. * Fixed bug where `col_breaks` was not working for a numeric `col`. diff --git a/vignettes/articles/3_go_further-Rmd.Rmd b/vignettes/articles/3_go_further-Rmd.Rmd index f6f445c4b..6e5311711 100644 --- a/vignettes/articles/3_go_further-Rmd.Rmd +++ b/vignettes/articles/3_go_further-Rmd.Rmd @@ -284,7 +284,7 @@ p1 / p2 ### 8. Add auto-contrast text on polygons -Text labels can be coloured based on the lightness/darkness of underlying polygons using a trick documented by [@teunbrand](https://github.com/teunbrand/ggplot_tricks). It requires `geom_text` to include the `show.legend = FALSE` argument. When using this method to make a flipped plot, use `coord_flip`. +Text labels can be coloured based on the lightness/darkness of underlying polygons using a trick documented by [@teunbrand](https://github.com/teunbrand/ggplot_tricks). It requires `geom_text` to include the `show.legend = FALSE` argument. ```{r} contrast <- function(colour) { @@ -299,24 +299,20 @@ penguins2 |> summarise(across(flipper_length_mm, \(x) mean(x, na.rm = TRUE))) |> ungroup() |> gg_col( - x = sex, - y = flipper_length_mm, + x = flipper_length_mm, + y = sex, col = species, position = "dodge", - width = 0.75 - ) + + width = 0.75) + geom_text( aes( - y = flipper_length_mm - (max(flipper_length_mm) * 0.05), - label = round(flipper_length_mm, 0),!!!aes(colour = after_scale(contrast(( - fill - )))) + x = flipper_length_mm - (max(flipper_length_mm) * 0.05), + label = round(flipper_length_mm, 0), + !!!aes(colour = after_scale(contrast((fill)))) ), show.legend = FALSE, size = 3.53, - position = position_dodge(width = 0.75) - ) + - coord_flip() + position = position_dodge(width = 0.75)) ``` ```{r} diff --git a/vignettes/articles/4_extensions-Rmd.Rmd b/vignettes/articles/4_extensions-Rmd.Rmd index 85317c7c3..3cbc104dc 100644 --- a/vignettes/articles/4_extensions-Rmd.Rmd +++ b/vignettes/articles/4_extensions-Rmd.Rmd @@ -417,7 +417,7 @@ penguins2 |> title = "***Pygoscelis*** **penguin** bill lengths and depths", subtitle = "**Adelie**, **Chinstrap**, - *and* **Gentoo**", + *and* **Gentoo**", x_labels = \(x) glue::glue("_{x}_"), y_labels = \(x) glue::glue("_{x}_"), col_labels = \(x) glue::glue("_{x}_"), diff --git a/vignettes/ggblanket.Rmd b/vignettes/ggblanket.Rmd index ae7f1725b..bb05d6342 100644 --- a/vignettes/ggblanket.Rmd +++ b/vignettes/ggblanket.Rmd @@ -452,8 +452,6 @@ p1 + p2 3. In some situations, `gg_blank` may be required. -4. If users are building a horizontal plot that includes multiple geoms, it is recommended that users build the plot vertically with ggblanket - and then use `ggplot2::coord_flip` to make it horizontally. - Users need to ensure that the scales built by their `gg_*` function are appropriate for subsequent layers. Plot scales are built by the `gg_*` function based on the `data`, `x`, `y`, `*_limits`, `*_include`, `stat`, `position` and `coord` arguments in the `gg_*` function. ```{r, fig.asp=0.75} @@ -466,34 +464,32 @@ d <- penguins2 |> p1 <- d |> gg_col( - x = species, - y = body_mass_g, + x = body_mass_g, + y = species, col = species, width = 0.75, - y_include = c(0, max(d$upper)), - y_labels = \(x) x / 1000, - y_title = "Body mass kg", + x_include = c(0, max(d$upper)), + x_labels = \(x) x / 1000, + x_title = "Body mass kg", col_legend_place = "n") + - geom_errorbar(aes(ymin = lower, ymax = upper), + geom_errorbar(aes(xmin = lower, xmax = upper), colour = "black", - width = 0.1) + - coord_flip() + width = 0.1) p2 <- d |> gg_col( - x = species, - y = body_mass_g, + x = body_mass_g, + y = species, col = species, colour = "#d3d3d3", fill = "#d3d3d3", width = 0.75, - y_include = c(0, max(d$upper)), - y_labels = \(x) x / 1000, - y_title = "Body mass kg", + x_include = c(0, max(d$upper)), + x_labels = \(x) x / 1000, + x_title = "Body mass kg", col_legend_place = "n") + - geom_errorbar(aes(ymin = lower, ymax = upper), - width = 0.1) + - coord_flip() + geom_errorbar(aes(xmin = lower, xmax = upper), + width = 0.1) p1 / p2 ```