Python 如何在不删除内容的情况下删除matplotlib中的轴线?
在下图中,我想擦除右上角绘图中的x轴和y轴,如何在不擦除文本的情况下执行此操作 我试过:Python 如何在不删除内容的情况下删除matplotlib中的轴线?,python,matplotlib,seaborn,Python,Matplotlib,Seaborn,在下图中,我想擦除右上角绘图中的x轴和y轴,如何在不擦除文本的情况下执行此操作 我试过: axes[m,k].get_yaxis().set_visible(False) axes[m,k].get_xaxis().set_visible(False) 但是它不起作用。您可以使用 ax.axis("off") 使用seabornPairGrid的示例: import seaborn.apionly as sns import matplotlib.pyplot as plt df =
axes[m,k].get_yaxis().set_visible(False)
axes[m,k].get_xaxis().set_visible(False)
但是它不起作用。您可以使用
ax.axis("off")
使用seaborn
PairGrid
的示例:
import seaborn.apionly as sns
import matplotlib.pyplot as plt
df = sns.load_dataset("iris")
g = sns.PairGrid(df, hue="species")
g.map_lower(sns.kdeplot, cmap="Blues_d")
g.map_diag(sns.kdeplot, lw=3, legend=False)
def text(x,y, color, label):
i = ["setosa", "versicolor","virginica"].index(label)
xm = x.mean(); ym = y.mean()
tx = "xmean: {}\nymean: {}".format(xm,ym)
plt.text(.3,0.1+i*0.25,tx, color=color, transform=plt.gca().transAxes)
plt.gca().axis("off")
g.map_upper(text)
plt.show()
您可以使用
ax.axis("off")
使用seaborn
PairGrid
的示例:
import seaborn.apionly as sns
import matplotlib.pyplot as plt
df = sns.load_dataset("iris")
g = sns.PairGrid(df, hue="species")
g.map_lower(sns.kdeplot, cmap="Blues_d")
g.map_diag(sns.kdeplot, lw=3, legend=False)
def text(x,y, color, label):
i = ["setosa", "versicolor","virginica"].index(label)
xm = x.mean(); ym = y.mean()
tx = "xmean: {}\nymean: {}".format(xm,ym)
plt.text(.3,0.1+i*0.25,tx, color=color, transform=plt.gca().transAxes)
plt.gca().axis("off")
g.map_upper(text)
plt.show()