Skip to content

Commit acedd67

Browse files
Merge pull request #28 from pepijn-devries/work-in-progress
Work in progress
2 parents ea7ff74 + 7dfc9b0 commit acedd67

File tree

13 files changed

+101
-20
lines changed

13 files changed

+101
-20
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: ggsankeyfier
22
Type: Package
33
Title: Create Sankey and Alluvial Diagrams Using 'ggplot2'
4-
Version: 0.1.8.0011
4+
Version: 0.1.8.0013
55
Authors@R: c(person("Pepijn", "de Vries", role = c("aut", "cre", "dtc"),
66
email = "pepijn.devries@outlook.com",
77
comment = c(ORCID = "0000-0002-7961-6646")),
@@ -27,7 +27,7 @@ Depends:
2727
R (>= 4.1.0)
2828
Imports:
2929
dplyr,
30-
ggplot2 (>= 3.4.4),
30+
ggplot2 (>= 4.0.0),
3131
grid (>= 4.1.0),
3232
gridBezier,
3333
methods,

NEWS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
ggsankeyfier v0.1.8.0011
1+
ggsankeyfier v0.1.8.0013
22
-------------
33

44
* Added better stacking order features
55
* Added `curve_weight` parameter to `geom_sankeyedge()`
66
* Added check workflow
77
* Added code coverage workflow and badge
88
* Improved test coverage
9-
* Expanded documentation
9+
* Expanded / corrected documentation
1010
* Fix for [issue #23](https://github.com/pepijn-devries/ggsankeyfier/issues/23)
1111

1212
ggsankeyfier v0.1.8

README.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ aspects are circled in the illustration below.
7070
The `ggsankeyfier` package can only visualise structured graphs. Meaning that each node
7171
belongs to a specific stage (arranged along the x-axis).
7272

73-
### Sankey thesaurus
73+
### Sankey Thesaurus
7474

7575
As there are no standards in Sankey diagrams, there may be different words representing the
7676
same or similar aspects. Therefore, the following thesaurus is presented to provide an overview

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ illustration below.
6464
The `ggsankeyfier` package can only visualise structured graphs. Meaning
6565
that each node belongs to a specific stage (arranged along the x-axis).
6666

67-
### Sankey thesaurus
67+
### Sankey Thesaurus
6868

6969
As there are no standards in Sankey diagrams, there may be different
7070
words representing the same or similar aspects. Therefore, the following

data-raw/animate.R

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
library(dplyr)
2+
library(gganimate)
3+
library(ggplot2)
4+
library(gridBezier)
5+
library(ragg)
6+
library(vwline)
7+
8+
x <- grid::unit(c(0.001, .25, 0.25, .499), "in")
9+
y <- grid::unit(c(0, 0, 1, 1), "in")
10+
width <- unit(c(.1), "in")
11+
pts <- BezierGrob(
12+
x, y, default.unit = "in",
13+
stepFn = gridBezier::nSteps(100)) |>
14+
gridBezier::BezierPoints() |>
15+
lapply(as.numeric) |>
16+
as.data.frame()
17+
pts <- bind_rows(
18+
data.frame(x = 0, y = 0),
19+
pts,
20+
data.frame(x = 0.5, y = 1),
21+
) |>
22+
mutate(w = width, frame = row_number())
23+
24+
labels <- data.frame(x = 0, y = 1, text = c("Perpendicular\nbrush", "Vertical\nbrush"),
25+
what = c("ggsankeyfier", "other packages"))
26+
27+
i_frames <- 3L:100L
28+
frames <- lapply(3L:100L, \(fr) {
29+
p_slice <- slice_head(pts, prop = fr/max(i_frames))
30+
lapply(list("perp", pi/2), \(an) {
31+
lapply(list(p_slice$y, rep(0, nrow(p_slice))), \(dat) {
32+
result <-
33+
vwline::vwXsplineGrob(
34+
p_slice$x, dat, p_slice$w, angle = an, default.units = "in") |>
35+
grobCoords()
36+
result[[1]][[1]] |> unclass() |> as.data.frame() |>
37+
mutate(what = ifelse(an == "perp", "ggsankeyfier", "other packages"),
38+
frame = fr,
39+
ref = ifelse(all(dat == 0), "Reference", "Curve") |>
40+
factor(c("Reference", "Curve")))
41+
}) |>
42+
bind_rows()
43+
}) |>
44+
bind_rows()
45+
}) |> bind_rows()
46+
47+
anim <-
48+
ggplot(frames |> mutate(ref = factor(ref, c("Reference", "Curve"))) |>
49+
arrange(ref)) +
50+
geom_polygon(aes(x = x, y = y, fill = ref)) +
51+
geom_segment(aes(x = x,
52+
xend = x,
53+
y = y - as.numeric(width)/2,
54+
yend = y + as.numeric(width)/2,
55+
), data = pts[i_frames,], col = "red") +
56+
geom_text(aes(x = x, y = y, label = text), data = labels, hjust = 0) +
57+
lims(x = c(0, 0.5), y = c(-.06, 1.06)) +
58+
coord_fixed() +
59+
labs(x = NULL, y = NULL, fill = NULL) +
60+
theme_light() +
61+
theme(axis.text = element_blank(), legend.position = "top") +
62+
scale_fill_brewer(palette = "Paired") +
63+
facet_wrap(~what) +
64+
transition_manual(frame)
65+
66+
anim <- animate(anim, device = "ragg_png", fps = 30,
67+
width = 400, height = 500,
68+
nframes = length(i_frames), res = 100)
69+
save_animation(anim, "data-raw/brushangle.gif")

data-raw/brushangle.gif

145 KB
Loading

man/geom_sankeyedge.Rd

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/geom_sankeynode.Rd

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/position_sankey.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/scale_waist.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)