[英]Seaborn Box Plot X-Axis Too Crowded
再會,
請參閱附圖以供參考。 我創建的 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)
我會很感激任何幫助。
謝謝!
您沒有使用在上一行設置的圖形大小。 嘗試
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)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.