Skip to content

fix: respect width aesthetic #6576

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

fix: respect width aesthetic #6576

wants to merge 1 commit into from

Conversation

Yunuuuu
Copy link
Contributor

@Yunuuuu Yunuuuu commented Aug 23, 2025

fix #6575

n <- vapply(
    split(mpg, ~cyl),
    function(d) length(unique(d$class)),
    integer(1L)
)

dplyr::mutate(mpg,
    width = length(unique(class)),
    median = length(unique(class)) / 2L,
    .by = cyl
) |>
    ggplot() +
    geom_boxplot(
        aes(median, hwy, group = median, width = width)
    ) +
    facet_wrap(vars(cyl), nrow = 1L, space = "free_x", scales = "free_x") +
    ggh4x::facetted_pos_scales(
        lapply(n, function(max) scale_x_continuous(limits = c(0, max)))
    )
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Respect width aes in geom_boxplot
1 participant