在seaborn barplot x轴python中换行文本

问题描述 投票:1回答:1

我正在尝试绘制数据框,并且希望x轴标签不会像此处那样相互覆盖

enter image description here

[处理一个图时,添加.set_xticklabels(rotation=30)确实解决了问题:

sns.catplot("foo", data=boo, aspect=5, kind="count" ).set_xticklabels(rotation=30)

enter image description here

但是当我在此处添加ax参数时:

sns.catplot("foo", data=boo, aspect=5, kind="count" , ax=fig.add_subplot(211) ),

没有(请参阅第一个快照)。

我尝试过sns.catplot("foo", data=boo, aspect=5, kind="count", ax=ax1).set_xticklabels(rotation=30)

我正在寻找某种excel的“自动换行”。我尝试查看海洋属性,但没有成功。我还尝试使x轴的值更小,但在某些标签中它仍然覆盖了每个值。

python label data-visualization customization seaborn
1个回答
0
投票

对于seaborn,这是不可能的,但是对于与seaborn类似的库dexplot,却有更多功能,这是可以的。

下面是带有长标签的条形图。它们会自动包装,但可以使用x_textwrapy_textwrap包裹在特定位置。

enter image description here

在seaborn中,相同的情节看起来像这样:

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.