Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

add swarm plot #5087

Copy link
Copy link
Open
Open
Copy link
@suterberg

Description

@suterberg
Issue body actions

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
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3backlogbacklogfeaturesomething newsomething new

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.