此问题已在此处有答案:
Rotate tick labels in subplot(3个答案)
How to change rotation of tick labels of a subplot(1个答案)
7天前关闭
如何将子图222(图2)的X轴标签旋转90°并保持使用sns。boxplot?
fig = plt.figure(figsize=(12, 8))
# CHART 1
fig.add_subplot(221)
#sns.countplot(df_train['MSZoning'])
sns.boxplot(x='MSZoning', y='SalePrice', data=df_train)
# CHART 2
fig.add_subplot(222)
#sns.boxplot(x='MSZoning', y='SalePrice', data=df_train)
sns.boxplot(x='Neighborhood', y='SalePrice', data=df_train)
# CHART 3
fig.add_subplot(223)
#sns.boxplot(x='Neighborhood', y='SalePrice', data=df_train)
sns.boxplot(x='OverallCond', y='SalePrice', data=df_train)
# CHART 4
fig.add_subplot(224)
#sns.violinplot(x = 'OverallQual', y = 'SalePrice', data=df_train, palette='Set3', bw=.2, cut=1, split=True, linewidth=1)
sns.boxplot(x='OverallQual', y='SalePrice', data=df_train)
绘图结果
已尝试:
ax.set_xticklabels(labels, rotation=45)
ax.tick_params(labelrotation=45)
1条答案
按热度按时间oxosxuxt1#
一种方法是获取特定绘图的轴(在您的情况下为222),然后将
tick_param()
设置为将标签旋转90度。下面的示例供您参考...输出图