简体   繁体   English

如何更改 seaborn 小提琴 plot 的 x 轴标签而不返回并更改数据?

[英]How can I change the labels of the x-axis of a seaborn violin plot without going back and changing the data?

I have the following seaborn violin plot:我有以下 seaborn 小提琴 plot:

sns.violinplot( x=c1_census['Cluster Labels'], y=c1_census['Land Area (km2)'],palette=my_pal)
plt.show()

在此处输入图像描述

How can I change the labels of the x-axis without going back and changing the data.如何在不返回并更改数据的情况下更改 x 轴的标签。 For example:例如:

Replacing 0 for A, 1 for B, 2 for C, 3 for D, 4 for E将 0 替换为 A,1 替换 B,2 替换 C,3 替换 D,4 替换 E

Thanks in advance!提前致谢!

You can use ax.set_xticklabels :您可以使用ax.set_xticklabels

ax = sns.violinplot( x=c1_census['Cluster Labels'], y=c1_census['Land Area (km2)'],palette=my_pal)
ax.set_xticklabels([*'ABCDE'])

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

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