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

Implement dodge by shifting each category if necessary, based on the dodge vector #7

Open
asinghvi17 opened this issue Mar 11, 2024 · 6 comments
Labels
enhancement New feature or request

Comments

@asinghvi17
Copy link
Member

asinghvi17 commented Mar 11, 2024

With all this handling, maybe we should move the category code into the recipe? But then there would be no control from the algorithm's end.

@TheCedarPrince
Copy link
Collaborator

To make sure I am understanding what you are saying with dodging, you are imagining a sort of dodging figure like this:

image

Out of curiosity, what is the process you are imagining? I am struggling to imagine what the API would look like with:

beeswarm(categories, ys, dodge = ?)

@asinghvi17
Copy link
Member Author

Yep, that's what I'd envision. Dodging would mutate the xs of position before applying calculate. Similar to bar/violin plots.

@TheCedarPrince
Copy link
Collaborator

Gotcha -- how would we want to handle dodge grouping? Would we want to just have an API like Makie's boxplot:

using CairoMakie

categories = rand(1:3, 1000)
values = randn(1000)
dodge = rand(1:2, 1000)

boxplot(categories, values, dodge = dodge, color = dodge)

Or were you thinking of something else?

@asinghvi17
Copy link
Member Author

Nope, it would be pretty much that. Maybe we could hoist the category utilization code out of calculate! and into the main onany block...

@TheCedarPrince
Copy link
Collaborator

Brilliant! Last question -- how would we want to gutterize! dodged groups? Would there be the typical gutter per category overall but then also like an inside_gutter dimension that would set thresholds inside the category between dodged groups?

What do you think @asinghvi17 ? Either way, I'll work on a naive implementation to see what I can do here. I like the idea of hoisting things by the way. But maybe, let's wait until we have the feature fleshed out some more before we do a bit more of an overhaul?

@asinghvi17
Copy link
Member Author

asinghvi17 commented Mar 15, 2024

I would imagine so - but that could also be based on the dodge width!

There is already a readymade utility function in Makie for dodging:
https://github.com/MakieOrg/Makie.jl/blob/14b65a0e8c786030f095cfe37860e6eaeec39eaa/src/basic_recipes/barplot.jl#L101-L115

and the way violin (probably the closest plot to a beeswarm) manages it is by using multiple attributes to control dodge.
https://github.com/MakieOrg/Makie.jl/blob/14b65a0e8c786030f095cfe37860e6eaeec39eaa/src/stats/violin.jl#L26-L29

@asinghvi17 asinghvi17 added the enhancement New feature or request label Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants