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

Ridgeline plot #71

Open
etiennebacher opened this issue Aug 22, 2023 · 4 comments
Open

Ridgeline plot #71

etiennebacher opened this issue Aug 22, 2023 · 4 comments

Comments

@etiennebacher
Copy link
Contributor

Hi @grantmcdermott, I was looking for how to make ridgeline plots in base R and I came across this package that has a single function to do it: https://github.com/R-CoderDotCom/ridgeline

It is MIT licensed so it should be fine to take the code. I'm not making a PR for this because I don't know what kind of implementation you'd prefer (formula, arguments, etc.) and because the code of the plot2.* functions is quite dense. I'm just putting this here so that you or someone else don't have to start from scratch if you choose/have time to implement this.

@grantmcdermott
Copy link
Owner

Nice, thanks. (That @karoliskoncevicius tutorial is fantastic btw. If/when I integrate ridgelines into plot2, I'll be sure to give him credit.)

the code of the plot2.* functions is quite dense

I know, it's becoming a bit unwieldy. I'm not a fan of monolithic function scripts, but some of that is unavoidable here to handle the correct passing between methods and plot types. I do want to try and pull out the legend drawing section into a separate, non-exported function at some point, though.

@grantmcdermott
Copy link
Owner

PS. I know it's not a ridgeline plot, but in the latest dev version you can at least do things like:

library(plot2)

plot2(~ weight | feed, chickwts, type = "density", bg = "by", col = "white", palette = "Zissou 1")

Created on 2023-08-22 with reprex v2.0.2

@zeileis
Copy link
Collaborator

zeileis commented Aug 23, 2023

Regarding the monolithic function and separating building blocks like the legend (or drawing axes). I had made this suggestion a while back which would need some further discussions and refinements before we could implement it, I guess. Note sure whether it is still feasible given how much the code grew since April: #2 (comment)

@grantmcdermott
Copy link
Owner

Thanks for the reminder @zeileis. I still like all of those suggestions and think we can reasonably separate out the legend drawing portion at outset (and then cycle through facets by updating par(mfg) during the group-based loop). This would at least solve your question of which component draws the legend, but we'd obviously have to test it first.

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

3 participants