首页 > 解决方案 > 在 Seaborn 中制作两个相邻的 BoxPlot

问题描述

我有两个清单:

true = [1,3,5,6,2,5,11,2,4,7,8,9,5,8,13]
fake = [5,3,8,7,5,3,13,8,9,13,15,11,8,9,19]

我想将其绘制Seabornboxplot,并用两种不同的颜色彼此相邻,红色为假货,蓝色为真货。另外,我想要垂直箱线图:

sns.boxplot(x = "true", y = true, color = "blue")
sns.boxplot(y = "fake", y = fake, color = "fake")
plt.show()

标签: pythonseaborn

解决方案


堆叠在同一轴上:

fig,ax = plt.subplots(1)
sns.boxplot(data=true, color = "blue",ax=ax) 
sns.boxplot(data=fake, color = "red",ax=ax) 
plt.show() 

推荐阅读