从Seaborn PairGrid删除轴标题 [英] Remove axis titles from Seaborn PairGrid
本文介绍了从Seaborn PairGrid删除轴标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试使用
解决方案
只需循环遍历子图并清除每个子图的标题即可.
将matplotlib.pyplot导入为plt将 seaborn 作为 sns 导入iris = sns.load_dataset('iris')g = sns.PairGrid(iris).map_diag(sns.distplot)对于 g.axes.flatten() 中的 ax:ax.set_ylabel('')ax.set_xlabel('')
I've tried using the answer to Hide Axis Titles in Seaborn, which applies to heatmap
, but end up with two plots instead: the first being an empty grid without axis titles, the second being the PairGrid
but still with axis titles. How can I hide the axis titles on the 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('')
解决方案
Just loop through the subplots and clear the titles for each of them.
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('')
这篇关于从Seaborn PairGrid删除轴标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文