gpt4 book ai didi

python - 从 Seaborn PairGrid 中删除轴标题

转载 作者:行者123 更新时间:2023-12-01 02:18:24 25 4
gpt4 key购买 nike

我尝试过使用answerHide Axis Titles in Seaborn ,它适用于 heatmap,但最终会得到两个图:第一个是没有轴标题的空网格,第二个是 PairGrid 但仍带有轴标题。如何隐藏 PairGrid 上的轴标题?

import matplotlib.pyplot as plt
import seaborn as sns

iris = sns.load_dataset('iris')

fig, ax = plt.subplots(1, 1, figsize = (10, 10), dpi=300)
sns.PairGrid(iris).map_diag(sns.distplot)
ax.set_ylabel('')
ax.set_xlabel('')

plot 1 - empty grid with no labels

plot 2 - normal plot with labels

最佳答案

只需循环遍历子图并清除每个子图的标题即可。

import matplotlib.pyplot as plt
import seaborn as sns

iris = sns.load_dataset('iris')

g = sns.PairGrid(iris).map_diag(sns.distplot)
for ax in g.axes.flatten():
ax.set_ylabel('')
ax.set_xlabel('')

plot result

关于python - 从 Seaborn PairGrid 中删除轴标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48162182/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com