Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhodge931 committed Nov 10, 2023
1 parent 965e965 commit a58f352
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 33 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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")),
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -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`.
Expand Down
20 changes: 8 additions & 12 deletions vignettes/articles/3_go_further-Rmd.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion vignettes/articles/4_extensions-Rmd.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ penguins2 |>
title = "***Pygoscelis*** **penguin** bill lengths and depths",
subtitle = "<span style = 'color: #2596be ;'>**Adelie**</span>,
<span style = 'color:#fc7c24;'>**Chinstrap**</span>,
*and* <span style = 'color:#6b5840;'>**Gentoo**</span>",
*and* <span style = 'color:#9c1e74;'>**Gentoo**</span>",
x_labels = \(x) glue::glue("_{x}_"),
y_labels = \(x) glue::glue("_{x}_"),
col_labels = \(x) glue::glue("_{x}_"),
Expand Down
32 changes: 14 additions & 18 deletions vignettes/ggblanket.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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
```
Expand Down

0 comments on commit a58f352

Please sign in to comment.