fig, axe = plt.subplots(2, 2, figsize=(10, 8))
sns.histplot(data=data, x='satisfaction_level', hue='left', kde=True, ax=axe[0, :])
sns.boxplot(data=data, y='satisfaction_level', width=0.3, ax=axe[1, 0])
sns.boxplot(data=data, y='satisfaction_level', x='left', width=0.3, ax=axe[1, 1])
如图,seaborn是否不支持这类的写法?
plt.subplot(grid[0, :])则不会报错
plt.figure(figsize=(10, 8))
grid = plt.GridSpec(2, 2, wspace=0.2, hspace=0.3)
plt.subplot(grid[0, :])
sns.histplot(data=data, x='satisfaction_level', hue='left', kde=True)
plt.subplot(grid[1, 0])
sns.boxplot(data=data, y='satisfaction_level', width=0.3)
plt.subplot(grid[1, 1])
sns.boxplot(data=data, y='satisfaction_level', x='left', width=0.3)
如图: