You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can't find swarm plot in plotly, but can use this way to plot a swarm map:
import plotly.express as px
import numpy as np
import pandas as pd
np.random.seed(1)
y0 = np.random.randn(50) - 1
mm=pd.DataFrame({"org":y0})
tmp=[]
for k in y0:
tmp.append(np.floor(k*10)/10)
mm["cut"]=tmp
cc=pd.DataFrame(columns=["x","y"])
width=0.08
for s in mm.groupby("cut"):
# print(type(s))
x=s[0]
mp=s[1]
ls=len(s[1])
mid= int(ls/2)
org= -mid
if ls%2==0:
org=org+0.5
for i in range(ls):
cc.loc[len(cc)]=[x,(i+org)*width]
# for i in range(ls):
# if i == mid:
# org=org+1
# cc.loc[len(cc)]=[x,(i+org)*width]
else:
for i in range(ls):
cc.loc[len(cc)]=[x,(i+org)*width]
# print(mm)
# print(cc)
fig = px.scatter(cc,x='x',y='y',range_y=[-2,2])
# fig=px.strip(cc,x='x',y='y',range_y=[-2,2])
fig.show()
this is a example for how to deal data and transform data for swarm
The text was updated successfully, but these errors were encountered:
I can't find swarm plot in plotly, but can use this way to plot a swarm map:
this is a example for how to deal data and transform data for swarm

The text was updated successfully, but these errors were encountered: