让我们有这样的数据:
import pandas as pd
import seaborn as sns
data = np.array([[5.2, 500, 1], [7.2, 450, 1],[6.2, 350, 1],[4.6, 400,1 ],[5.9, 212,1], [6.2, 350, 2],[4.6, 400,2 ],[5.9, 212,2]])
df = pd.DataFrame({'val':data[:,0],'size':data[:,1], 'time':data[:,2]})
val
-实际平均值,由中指定大小的数据集计算得出
size
绘制箱线图:
ax = sns.boxplot (x = 'time', y="val", data=df)
ax = sns.swarmplot(x = 'time', y="val", data=df, color=".25", size = df.size )
瓦尔
除以
大小
对于每个
time
relplot
帮助以适当的大小绘制点的大小,但如何绘制真正的箱线图:
ax = sns.relplot(x = 'time', y="val", size="size",dashes = True,
sizes=(40, 400), alpha=.5, palette="muted",
height=6, data=df)