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

Enhancement: Pass additional aesthetics to quantile_fun (e.g., for weighted quantiles)? #74

Open
LukasWallrich opened this issue Feb 9, 2022 · 4 comments

Comments

@LukasWallrich
Copy link
Contributor

I would like to show weighted medians in geom_density_ridges(). The most intuitive way to get there would be to pass x and weight to my quantile_fun ... but I don't think that is possible at present.

Unless I am overlooking a simpler solution, might that be a worthwhile enhancement? I could also see use cases where it would be helpful to have y within that function, for instance, to show different thresholds depending on y ...

@clauswilke
Copy link
Collaborator

There's an abandoned PR about this: #59. Feel free to pick up and finish off.

@LukasWallrich
Copy link
Contributor Author

I understand that PR as wanting to add weights to the density calculation - not to the quantile lines? Would one solve the other? Then I'd certainly want to investigate.

@clauswilke
Copy link
Collaborator

Oh, sorry, I didn't read carefully enough. Those are two separate issues. It's possible already though to provide your own quantile function. Does that help?

@LukasWallrich
Copy link
Contributor Author

Not cleanly - I would like to use a weighted.median(x, weight) function, but can't pass the weight in there.

As a workaround, I could probably calculate the desired outputs first and then use x just as a lookup value in my own function ... these vectors better be unique for each y value. That obviously is rather hacky ... but good enough for now. If I get to understand the ggplot2 architecture properly at some point, I will return with a PR.

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

No branches or pull requests

2 participants