Skip to content
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

Weighted ellipses #6186

Merged
merged 5 commits into from
Jan 27, 2025
Merged

Weighted ellipses #6186

merged 5 commits into from
Jan 27, 2025

Conversation

teunbrand
Copy link
Collaborator

This PR aims to fix #5272.

Briefly, it adds a weight aesthetic to stat_ellipse().

I don't know enough about data ellipses to verify the correctness of this approach.

In the example, we can see that the solid, weighted ellipses are shifted to the right because observations to the right have higher weights than those to the left.

devtools::load_all("~/packages/ggplot2")
#> ℹ Loading ggplot2

ggplot(faithful, aes(waiting, eruptions, color = eruptions > 3)) +
  geom_point() +
  stat_ellipse(alpha = 0.3) +
  stat_ellipse(aes(weight = rescale(waiting)))

Created on 2024-11-15 with reprex v2.1.1

Copy link
Member

@thomasp85 thomasp85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@teunbrand teunbrand merged commit aa6ee95 into tidyverse:main Jan 27, 2025
13 checks passed
@teunbrand teunbrand deleted the weighted_ellipses branch January 27, 2025 14:21
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.

Weight parameter for stat_ellipse()
2 participants