简体   繁体   English

Seaborn 盒子 Plot X 轴过于拥挤

[英]Seaborn Box Plot X-Axis Too Crowded

Good Day,再会,

See the attached image for reference.请参阅附图以供参考。 The x-axis on the Seaborn bar chart I created has overlapping text and is too crowded.我创建的 Seaborn 条形图上的 x 轴有重叠的文本,并且过于拥挤。 How do I fix this?我该如何解决?

The data source is on Kaggle and I was following along with this article: https://towardsdatascience.com/a-quick-guide-on-descriptive-statistics-using-pandas-and-seaborn-2aadc7395f32数据源在 Kaggle 上,我一直在关注这篇文章: https://towardsdatascience.com/a-quick-guide-on-descriptive-statistics-using-pandas-and-seaborn-2aadc7395f32

Here is the code I used:这是我使用的代码:

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

Seaborn X-axis too crowded Seaborn X轴太挤

I'd appreciate any help.我会很感激任何帮助。

Thanks!谢谢!

You are not using the figure size you set on the previous line.您没有使用在上一行设置的图形大小。 Try尝试

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

An extra thing after this might be to rotate the labels:之后的额外事情可能是旋转标签:

ax.set_xticklabels(ax.get_xticklabels(), rotation=60)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM