Experiment
library(tidyverse)
palmerpenguins::penguins |>
filter(sex == "female") |>
mutate(id = row_number()) |>
ggplot() +
aes(x = species) +
layer(geom = "bar",
stat = "count",
position = "stack",
params = list(
width = .25,
fill = "white",
color = "grey35",
linewidth = .05
)) +
aes(group = id)
library(tidyverse)
palmerpenguins::penguins |>
mutate(id = row_number()) |>
ggplot() +
aes(x = bill_depth_mm) +
geom_histogram(color = "white",
linewidth = .2) +
aes(group = id) +
aes(fill = sex)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 2 rows containing non-finite outside the scale range
## (`stat_bin()`).
palmerpenguins::penguins |>
filter(sex == "female") |>
mutate(id = row_number()) |>
ggplot() +
aes(x = species) +
layer(geom = ggproto("GeomBrick",
GeomBar,
default_aes = aes(fill = "white",
color = "grey35",
linewidth = .05)),
stat = "count",
position = "stack",
params = list(
width = .25
)) +
aes(group = id)
## Warning in rep(alpha, length.out = length(colour)): 'x' is NULL so the result
## will be NULL
palmerpenguins::penguins |>
filter(sex == "female") |>
mutate(id = row_number()) |>
ggplot() +
aes(x = species) +
layer(geom = ggproto("GeomBrick",
GeomBar,
default_aes = aes(fill = "white",
color = "grey35",
linewidth = .05)),
stat = ggproto("StatCountId", StatCount,
compute_group = function(data, scales){
StatCount$compute_group(data, scales) %>%
mutate(group = row_number())},
# default_aes = aes(group = after_stat(id))
),
position = "stack",
params = list(
width = .25
)) +
aes(group = id)
## Warning in rep(alpha, length.out = length(colour)): 'x' is NULL so the result
## will be NULL
# layer_data()
library(tidyverse)
compute_group_bricks <- function(data, scales){
data %>%
mutate(id = row_number()) %>%
mutate(y = id - .5)
}
StatBricks <- ggproto("StatBricks", Stat,
compute_group = compute_group_bricks)
palmerpenguins::penguins |>
filter(sex == "female") |>
ggplot() +
aes(x = species) +
geom_tile(stat = StatBricks,
width = .2)
palmerpenguins::penguins |>
filter(sex == "female") |>
ggplot() +
aes(x = species) +
geom_dotplot()
## Bin width defaults to 1/30 of the range of the data. Pick better value with
## `binwidth`.
library()
StatBrickStack <- ggproto("StatBrickStack",
Stat,
compute_group = compute_group_bricks)
palmerpenguins::penguins |>
filter(sex == "female") |>
ggplot() +
aes(x = species) +
layer(stat = StatBrickStack,
geom = ggproto("GeomBricks",
GeomTile,
default_aes =
aes(!!!modifyList(
GeomTile$default_aes,
aes(color = "grey35",
fill = "white",
linewidth = .1)
))
),
position = "identity",
params = list(width = .2))
GeomTile$default_aes
## Aesthetic mapping:
## * `fill` -> "grey20"
## * `colour` -> NA
## * `linewidth` -> 0.1
## * `linetype` -> 1
## * `alpha` -> NA
## * `width` -> NA
## * `height` -> NA