plotly / plotly.js

Open-source JavaScript charting library behind Plotly and Dash
https://plotly.com/javascript/
MIT License
16.94k stars 1.86k forks source link

add swarm plot #4021

Open nicolaskruchten opened 5 years ago

nicolaskruchten commented 5 years ago

Placeholder issue for a 'swarm' trace type that would behave much like box with and invisible box and points: "all"and some more-controllable jittering/overlap-avoidance options.

tsloan1377 commented 3 years ago

I needed to recreate a swarm plot in Plotly graph_objects for a project, effectively using a boxplot with invisible boxes was the way to go.

Posting the code here in case someone follows my same steps to this thread:

import plotly.graph_objects as go
import numpy as np

np.random.seed(1)
y0 = np.random.randn(50) - 1
y1 = np.random.randn(50) + 1

fig = go.Figure()
fig.add_trace(go.Box(y=y0, 
                     opacity=1,
                    fillcolor="rgba(0,0,0,0)",
                    boxpoints="all",
                    jitter=0.8,
                    line={
                        "width": 0
                    },
                    pointpos=0))
fig.add_trace(go.Box(y=y1, 
                    boxpoints="all",
                    fillcolor="rgba(0,0,0,0)",
                    jitter=0.8,
                    line={
                        "width": 0
                    },
                    pointpos=0))

fig.update_layout(showlegend=False)
fig.show()

newplot (6)

nicolaskruchten commented 3 years ago

Thanks Tyler! This is in effect what px.strip() does: https://plotly.com/python/strip-charts/

franktoffel commented 1 year ago

What's the current status of this?

Do you have any plans to include beeswarm plots?

This is a very common visualization: https://community.plotly.com/t/shap-like-bee-swarm-plots/68015 https://datascience.stackexchange.com/questions/71709/how-is-the-beeswarm-plot-better-than-a-histogram