matplotlibswarmplot

How to create a swarm plot with matplotlib


I know the question is not very informative.. but as I do not know the name of his type of plot, I can not be more informative..

[EDIT] I changed the title, and now it is more informative...

enter image description here


Solution

  • You can do something similar with seaborn.swarmplot. I also use seaborn.boxplot (with the whiskers and caps turned off) to plot the mean and range:

    import matplotlib.pyplot as plt
    import seaborn as sns
    sns.set_style("whitegrid")
    tips = sns.load_dataset("tips")
    ax = sns.swarmplot(x="day", y="total_bill", data=tips)
    ax = sns.boxplot(x="day", y="total_bill", data=tips,
            showcaps=False,boxprops={'facecolor':'None'},
            showfliers=False,whiskerprops={'linewidth':0})
    
    plt.show()
    

    enter image description here