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

Feature requests: Asymmetric swarmplot function #3554

Open
sunroofgod opened this issue Nov 9, 2023 · 2 comments
Open

Feature requests: Asymmetric swarmplot function #3554

sunroofgod opened this issue Nov 9, 2023 · 2 comments

Comments

@sunroofgod
Copy link

Hi!

I wanted to check how open the seaborn team would be to adding an additional param to the swarmplot() function to plot asymmetric swarmplots as well.

For example, users could potentially call

  1. with a new param side: "r" | "l" | "c", which represents the sides "right", "left", "center" respectively that the swarm plot would be aligned against. ("center" would be the same as how the swarmplots are currently being plotted)
import seaborn as sns

tips = sns.load_dataset("tips")
sns.swarmplot(data=tips, x="day", y="total_bill", hue="day", legend=False, side="right")
  1. perhaps in more alignment with the API of the current violinplot() function, a new param split instead could be used to reproduce the same plot as the one above.
sns.swarmplot(data=tips, x="day", y="total_bill", hue="day", legend=False, split=True)

Both of which would result in the following plot below:

swarmplot_side= right

(The plot above has been produced via code edits I've made to the current swarmplot() function wrt point 1.)

To sum it up,

  • Do you think this feature could be added to seaborn?
  • Would code snippets of the edits I've made be helpful for this process?
  • If yes to all of the above, what else can I do to help?

Thank you so much!

@mwaskom
Copy link
Owner

mwaskom commented Nov 28, 2023

I think this poses some tricky API issues.

  1. Several of the categorical functions produce asymmetrical plots that might make sense to draw "half" of this way. Would adding this just to swarmplot introduce new API inconsistencies?

  2. While you mention that violinplot has a similar feature, it's not identical: a single split violin (as of v0.13.0 where this became possible) spans the entire width of the space allotted for a non-split violin. Maybe that is actually not ideal and it would be better for odd splits to occupy half the space, but that does mean that just adding split to swarmplot to make the plot you're showing above doesn't make much sense.

  3. What happens with hue is used? Would you have multiple colors on swarms with the shapes your'e showing above? People would probably want, if not expect, that the swarm might "split" the way the violin plot does (they certainly would if the split parameter is used).

@sunroofgod
Copy link
Author

Hi, thank you so much for the reply! Will look into the concerns you've brought up and get back to you again once we have something more substantial.

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

No branches or pull requests

2 participants