Skip to content

Commit

Permalink
don't default alpha to face
Browse files Browse the repository at this point in the history
  • Loading branch information
corybrunson committed Mar 10, 2024
1 parent 80a9918 commit 1d69eb3
Show file tree
Hide file tree
Showing 16 changed files with 11,768 additions and 11,761 deletions.
6 changes: 3 additions & 3 deletions R/simplicial-complex.R
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ StatSimplicialComplex <- ggproto(

required_aes = c("x", "y"),

# Alternatively, could assign fill = after_stat(dimension)
default_aes = aes(alpha = after_stat(face)),
# default_aes = aes(fill = after_stat(dimension))
# default_aes = aes(alpha = after_stat(face))

compute_group = function(
data, scales,
Expand Down Expand Up @@ -370,7 +370,7 @@ GeomSimplicialComplex <- ggproto(
grob
},

default_aes = aes(colour = "black", fill = "grey30", alpha = NA,
default_aes = aes(colour = "black", fill = "grey30", alpha = .15,
linewidth = 0.5, linetype = 1,
shape = 21L, size = 1.5, stroke = .5),

Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ gridExtra::grid.arrange(
p_d, p_sc,
layout_matrix = matrix(c(1, 2), nrow = 1)
)
#> Warning: Using alpha for a discrete variable is not advised.
```

<img src="man/figures/README-unnamed-chunk-5-1.png" width="100%" />
Expand Down Expand Up @@ -265,7 +264,6 @@ ggplot(dg, aes(x, y)) +
) +
theme_bw() +
theme(legend.position = "none")
#> Warning: Using alpha for a discrete variable is not advised.
```

<img src="man/figures/README-unnamed-chunk-10-1.png" width="100%" />
Expand Down Expand Up @@ -298,7 +296,8 @@ ggplot(ds, aes(dataset = d)) +
labs(x = "Birth", y = "Death", color = "Dimension", shape = "Dimension") +
lims(x = c(0, max_prox), y = c(0, max_prox)) +
theme_persist()
#> Warning: Removed 2 rows containing missing values (`geom_point()`).
#> Warning: Removed 2 rows containing missing values or values outside the scale range
#> (`geom_point()`).
```

<img src="man/figures/README-unnamed-chunk-11-1.png" width="100%" />
Expand Down
20 changes: 10 additions & 10 deletions inst/examples/ex-draw-key-simplex.R
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@

# regular pentagon
fifths <- (seq_len(5) - 1) * 2 * pi / 5
pentagon <- data.frame(x = cos(fifths), y = sin(fifths))
ggplot(pentagon, aes(x, y)) +
# regular septagon
sevenths <- (seq_len(7) - 1) * 2 * pi / 7
septagon <- data.frame(x = cos(sevenths), y = sin(sevenths))
ggplot(septagon, aes(x, y)) +
geom_simplicial_complex(
diameter = 2, dimension_max = 5L, one_simplices = "all",
diameter = 1.6, dimension_max = 5L, one_simplices = "all",
engine = "simplextree",
aes(color = after_stat(factor(dimension)),
fill = after_stat(factor(dimension))),
alpha = .5
)

# regular septagon
sevenths <- (seq_len(7) - 1) * 2 * pi / 7
septagon <- data.frame(x = cos(sevenths), y = sin(sevenths))
ggplot(septagon, aes(x, y)) +
# regular pentagon
fifths <- (seq_len(5) - 1) * 2 * pi / 5
pentagon <- data.frame(x = cos(fifths), y = sin(fifths))
ggplot(pentagon, aes(x, y)) +
geom_simplicial_complex(
diameter = 1.6, dimension_max = 5L, one_simplices = "all",
diameter = 2, dimension_max = 5L, one_simplices = "all",
engine = "simplextree",
aes(color = after_stat(factor(dimension)),
fill = after_stat(factor(dimension))),
Expand Down
22 changes: 18 additions & 4 deletions inst/examples/ex-simplicial-complex.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,31 @@ df <- data.frame(
y = sin(s) + rnorm(40, 0, .1)
)

# default, visualizing dimension w/ alpha:
# default
ggplot(df, aes(x, y)) +
coord_fixed() +
geom_simplicial_complex(radius = .4)
# visualizing dimension w/ fill:
# higher-dimensional simplices are not more opaque but cause overlap
ggplot(df, aes(x, y)) +
coord_fixed() +
geom_simplicial_complex(radius = .4, dimension_max = 3L)

# visualizing dimension w/ face & alpha:
ggplot(df, aes(x, y)) +
coord_fixed() +
geom_simplicial_complex(
mapping = aes(alpha = after_stat(face)),
radius = .3, dimension_max = 4L
) +
scale_alpha_ordinal(range = c(.1, .6))
# visualizing dimension w/ dimension & fill:
ggplot(df, aes(x, y)) +
coord_fixed() +
geom_simplicial_complex(
mapping = aes(fill = after_stat(dimension)),
alpha = .5, radius = .4
)
radius = .3, dimension_max = 4L, alpha = .25
) +
scale_fill_continuous(type = "viridis")

# with a zero radius or diameter
ggplot(df, aes(x = x, y = y)) +
Expand Down
20 changes: 10 additions & 10 deletions man/draw_key.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified man/figures/README-unnamed-chunk-10-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-11-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-5-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-8-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 18 additions & 5 deletions man/simplicial_complex.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 1d69eb3

Please sign in to comment.