import matplotlib.pyplot as plt
import seaborn as sns
sns.set(style="dark", context="talk")
rs = np.random.RandomState(8)
f, (ax1, ax2, ax3) = plt.subplots(3, 1, figsize=(7, 5), sharex=True) # 分三张图,尺寸为7:5 且共享坐标轴
x = np.array(list("ABCDEFGHIJ"))
y1 = np.arange(1, 11)
sns.barplot(x=x, y=y1, palette="rocket", ax=ax1) # 第一张图设置
ax1.axhline(0, color="k", clip_on=False) # 轴上加一条水平线
ax1.set_ylabel("Sequential") # y轴标题
y2 = y1 - 5.5
sns.barplot(x=x, y=y2, palette="vlag", ax=ax2)
ax2.axhline(0, color="k", clip_on=False)
ax2.set_ylabel("Diverging")
y3 = rs.choice(y1, len(y1), replace=False) # 随机从y1中选取len(y1)个 replac=False不放回
sns.barplot(x=x, y=y3, palette="deep", ax=ax3)
ax3.axhline(0, color="k", clip_on=False)
ax3.set_ylabel("Qualitative")
sns.despine(bottom=True) # 去掉坐标底线
plt.setp(f.axes, yticks=[]) # 删除y坐标刻度
plt.tight_layout(h_pad=2) # 自动调整子图参数
path = ***
plt.savefig(path + "filename.png")
plt.show()
![](https://img2018.cnblogs.com/blog/1552994/201908/1552994-20190812121708368-212426458.png)