library(tidyverse)
library(ggwordcloud)
library(ggstamp)
extension_exported <- "https://raw.githubusercontent.com/EvaMaeRey/mytidytuesday/refs/heads/main/2024-11-19-gg-prefixes/exported_funs_exts_ggplot2_tidyverse_org.csv" |> read_csv()
## Rows: 5527 Columns: 3
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (3): user, repo, fun_exported
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
extension_exported %>%
distinct(user)
## # A tibble: 110 × 1
## user
## <chr>
## 1 YaoxiangLi
## 2 thomasp85
## 3 lionel-
## 4 aphalo
## 5 jrnold
## 6 IndrajeetPatil
## 7 brandmaier
## 8 jtlandis
## 9 corybrunson
## 10 const-ae
## # ℹ 100 more rows
The ggplot2 extension gallery helps people explore the ggplot2 extension ecosystem. Package developers can submit their extension packages to help others find their work. About 140 packages have been submitted
The star contains packages names, with larger sized names corresponding to packages with greater numbers of exported functions.
Branches and background contain exported function names. There are more than 5000 exported functions in the submitted packages.
The tree trunk is made up of package authors (github user). More than 100 unique package authors have contributed to the ecosystem.
lightparser::split_to_tbl("tree-w-ggwordcloud.Rmd") %>%
filter(section %in% c("website", "star", "branches", "trunk")) %>%
filter(type == "inline") %>%
unnest(cols = text) %>%
filter(text != "") %>%
select(section, text) ->
inline_text
## It seems you are currently knitting a Rmd/Qmd file. The parsing of the file will be done in a new R session.
inline_text$text
## [1] "The ggplot2 extension gallery helps people explore the ggplot2 extension ecosystem. Package developers can submit their extension packages to help others find their work. About 140 packages have been submitted "
## [2] "The star contains packages names, with larger sized names corresponding to packages with greater numbers of exported functions."
## [3] "Branches and background contain exported function names. There are more than 5000 exported functions in the submitted packages. "
## [4] "The tree trunk is made up of package authors (github user). More than 100 unique package authors have contributed to the ecosystem. "
ggplot(cars) +
aes(speed, dist) +
geom_point() +
annotate(ggtext::GeomTextBox,
x = I(.05),
y = I(c(.95, .75, .5, .25)),
label = inline_text$text,
hjust = 0, vjust = 1, size = 8,
width = unit(5, "inch"), fill = "lavender"
) +
theme_void()
# background
ggplot() +
geom_text_wordcloud(
aes(label = fun_exported, size = 2),
data = extension_exported %>%
sample_n(1100),
shape = "square", alpha = .2) +
ggstamp::theme_void_fill(fill = "whitesmoke") +
NULL ->
background; background
## Warning in wordcloud_boxes(data_points = points_valid_first, boxes = boxes, :
## Some words could not fit on page. They have been placed at their original
## positions.
# Star
ggplot() +
geom_text_wordcloud(
aes(label = repo, size = n),
data = extension_exported %>% count(repo),
shape = "star", color = "goldenrod4", y = .87) +
theme_void() +
# labs(title = "ggplot2 extensions on") +
# annotate("text", x = I(.1), y = I(.87),
# label = "More than Extension packages...", size = 8) +
NULL ->
star; star
# branches
ggplot() +
geom_text_wordcloud(
aes(label = fun_exported, size = 2),
data = extension_exported %>%
sample_n(500) %>%
filter(str_count(fun_exported) < 18),
shape = "triangle-upright",
color = "darkseagreen4", y = .4) +
theme_void() +
NULL ->
branches; branches
# base
ggplot() +
geom_text_wordcloud(
data = extension_exported %>% count(user),
aes(label = user),
shape = "square", color = "burlywood4", x = .5, y = .1) +
theme_void() +
annotate(ggtext::GeomTextBox,
x = I(c(.05, .65, .12, .1)),
y = I(c(.95, .85, .6, .2)),
label = inline_text$text,
hjust = 0, vjust = 1,
size = c(10,8,8,8),
width = unit(5, "inch"), fill = "lavender"
) +
NULL ->
base; base
ggsave("background.png", background, width = 20, height = 20)
ggsave("star.png", star, width = 20, height = 20)
ggsave("branches.png", branches, width = 20, height = 20)
ggsave("base.png", base, width = 20, height = 20)
library(magick)
## Linking to ImageMagick 6.9.12.93
## Enabled features: cairo, fontconfig, freetype, heic, lcms, pango, raw, rsvg, webp
## Disabled features: fftw, ghostscript, x11
c(image_read("background.png"),
image_read("star.png"),
image_read("branches.png"),
image_read("base.png")
) %>%
magick::image_flatten() %>%
magick::image_write("tree.png")
image_read("tree.png")
knitr::knit_exit()