在 Python seaborn 包中控制刻度标签
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32542957/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Control tick labels in Python seaborn package
提问by dsaxton
I have a scatter plot matrix generated using the seaborn
package and I'd like to remove all the tick mark labels as these are just messying up the graph (either that or just remove those on the x-axis), but I'm not sure how to do it and have had no success doing Google searches. Any suggestions?
我有一个使用该seaborn
包生成的散点图矩阵,我想删除所有刻度线标签,因为它们只是弄乱了图形(或者只是删除了 x 轴上的那些),但我不确定如何做到这一点并且在谷歌搜索中没有成功。有什么建议?
import seaborn as sns
sns.pairplot(wheat[['area_planted',
'area_harvested',
'production',
'yield']])
plt.show()
采纳答案by mwaskom
回答by Alexander
You can use a list comprehension to loop through all columns and turn off visibility of the xaxis.
您可以使用列表理解来遍历所有列并关闭 xaxis 的可见性。
df = pd.DataFrame(np.random.randn(1000, 2)) * 1e6
sns.pairplot(df)
plot = sns.pairplot(df)
[plot.axes[len(df.columns) - 1][col].xaxis.set_visible(False)
for col in range(len(df.columns))]
plt.show()
You could also rescale your data to something more readable:
您还可以将数据重新调整为更具可读性的内容:
df /= 1e6
sns.pairplot(df)