Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/352.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在不删除内容的情况下删除matplotlib中的轴线?_Python_Matplotlib_Seaborn - Fatal编程技术网

Python 如何在不删除内容的情况下删除matplotlib中的轴线?

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 =

在下图中,我想擦除右上角绘图中的x轴和y轴,如何在不擦除文本的情况下执行此操作

我试过:

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()