且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用Matplotlib创建群图

更新时间:2023-11-21 14:51:28

你可以用 seaborn.swarmplot 做类似的事情.我还使用 seaborn.boxplot (关闭了晶须和盖帽)来绘制平均值和范围:

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()