Skip to content

Commit

Permalink
Add leaf shapes #10
Browse files Browse the repository at this point in the history
  • Loading branch information
cgoo4 committed Jun 24, 2024
1 parent edfbf2b commit 7e13384
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 9 deletions.
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# ggfoundry (development version)

- New `display_palette()` uses a fillable shape for palette and hex codes.
- 2 shapes ("oak" & "hibiscus") added to a "leaf" set (#10).
- New `display_palette()` uses a fillable shape for palette & hex codes (#9).
- Uses `cli_abort`, instead of `abort`, for error message handling.
- Added use of `use_spell_check()`.

Expand Down
Binary file modified R/sysdata.rda
Binary file not shown.
16 changes: 9 additions & 7 deletions tests/testthat/_snaps/geom_casting.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@
33 geom dendro
35 geom ribbon
37 geom violin
39 penguin adelie
41 penguin chinstrap
43 penguin gentoo
45 polygon heptagon
47 polygon hexagon
49 polygon octagon
51 polygon pentagon
39 leaf hibiscus
41 leaf oak
43 penguin adelie
45 penguin chinstrap
47 penguin gentoo
49 polygon heptagon
51 polygon hexagon
53 polygon octagon
55 polygon pentagon

33 changes: 33 additions & 0 deletions vignettes/example_uses.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ suppressPackageStartupMessages(library(dplyr))
library(paletteer)
library(scales)
library(palmerpenguins)
library(rpart)
library(ggdendro)
```

## Exhibit a palette
Expand Down Expand Up @@ -105,3 +107,34 @@ count_df |>
) +
guides(shape = guide_legend(override.aes = list(size = 8)))
```

## Leafy dendrograms

Adding appropriate filled shapes to a dendrogram can help draw attention to important groupings. Shapes from ggfoundry's "leaf" set are used here to augment a [ggdendro](https://github.com/andrie/ggdendro) plot.

```{r}
data <-
rpart(Kyphosis ~ Age + Number + Start, data = kyphosis) |>
dendro_data()
ggplot() +
geom_segment(
aes(x, y, xend = xend, yend = yend),
colour = "tan4", data = data$segments,
) +
geom_label(
aes(x, y, label = label),
size = 3, fill = "seashell", data = data$labels) +
geom_casting(aes(x, y, shape = label, fill = label),
colour = "tan4", size = 0.27, data = data$leaf_labels) +
scale_shape_manual(values = c("hibiscus", "oak")) +
scale_fill_manual(values = c("olivedrab3", "darkorange")) +
labs(title = "Leafy Dendrogram", shape = "Kyphosis", fill = "Kyphosis") +
theme_dendro() +
theme(
plot.title = element_text(hjust = 0.5),
legend.key.size = unit(2, "line"),
legend.position = "top"
)
```

2 changes: 1 addition & 1 deletion vignettes/ggfoundry.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ After travelling the mountains, seas and forests of the world in search of that

These modest starter sets are included with the package. You can "mix and match" shapes from different sets; the "set" is for grouping shapes in the documentation and for use in `shapes_cast()` to filter for the desired shapes.

```{r sets, echo=FALSE, message=FALSE, warning=FALSE, fig.height=6}
```{r sets, echo=FALSE, message=FALSE, warning=FALSE, fig.height=7}
library(dplyr)
library(forcats)
Expand Down

0 comments on commit 7e13384

Please sign in to comment.