简体   繁体   中英

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. 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

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

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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