1

再会,

请参阅附图以供参考。我创建的 Seaborn 条形图上的 x 轴有重叠的文本并且过于拥挤。我该如何解决?

数据源在 Kaggle 上,我一直在关注这篇文章:https ://towardsdatascience.com/a-quick-guide-on-descriptive-statistics-using-pandas-and-seaborn-2aadc7395f32

这是我使用的代码:

 sns.set(style = 'darkgrid')
 plt.figure(figsize = (20, 10))
 ax = sns.countplot(x = 'Regionname', data = df)

Seaborn X 轴过于拥挤

我会很感激任何帮助。

谢谢!

4

1 回答 1

0

您没有使用在上一行设置的图形大小。尝试

fig, ax = plt.subplots(figsize=(20, 10))  # generate a figure and return figure and axis handle

sns.countplot(x='Regionname', data=df, ax=ax)  # passing the `ax` to seaborn so it knows about it

之后的额外事情可能是旋转标签:

ax.set_xticklabels(ax.get_xticklabels(), rotation=60)
于 2021-03-28T19:54:46.767 回答