Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/292.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_Visualization - Fatal编程技术网

Python 在Matplotlib中,轴如何被轻视?

Python 在Matplotlib中,轴如何被轻视?,python,matplotlib,seaborn,visualization,Python,Matplotlib,Seaborn,Visualization,我正在努力使下面的网格图更清晰一点。我不希望左侧和底部的记号重叠。我试图通过尝试下面的代码来鄙视Axis,但它似乎不起作用。有人有什么建议吗 fig, ax = plt.subplots(figsize=(15,10)) cols = ['x6', 'x7', 'x16', 'x17'] subset = df[cols] normed_df = (subset-subset.min())/(subset.max()-subset.min()) style.use('seaborn-darkgr

我正在努力使下面的网格图更清晰一点。我不希望左侧和底部的记号重叠。我试图通过尝试下面的代码来鄙视Axis,但它似乎不起作用。有人有什么建议吗

fig, ax = plt.subplots(figsize=(15,10))
cols = ['x6', 'x7', 'x16', 'x17']
subset = df[cols]
normed_df = (subset-subset.min())/(subset.max()-subset.min())
style.use('seaborn-darkgrid')
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
ax.spines['left'].set_visible(False)
ax.spines['bottom'].set_visible(False)
for sp in range(4):
    ax = fig.add_subplot(2,2, sp+1)
    ax.hist(normed_df[cols[sp]], density=True)
    normed_df[cols[sp]].plot.kde(ax=ax)
ax.tick_params(bottom="off", top="off", left="off", right="off")

运行上述代码后,我得到了以下绘图,但是,记号仍然重叠。

当您调用
plt.subplot()
而不指定网格时,它会在整个图形上创建那些轴,这些轴的记号和标签会干扰最终绘图中的子图记号标签。因此,将第一行代码更改为:

fig, ax = plt.subplots(2, 2, figsize=(15,10))

当您在不指定网格的情况下调用
plt.subplot()
时,它会在整个地物上创建那些轴,这些轴的记号和标签会干扰最终绘图中的子地块记号标签。因此,将第一行代码更改为:

fig, ax = plt.subplots(2, 2, figsize=(15,10))

要么按照@Arne的建议做:

fig, ax = plt.subplots(rows, cols) #makes a grid of subplots
或者将您的前两行写为:

fig, ax = plt.subplots(figsize=(15,10))
ax.axis('off')

这将在添加附加子批次之前删除整个子批次周围的轴

或者按照@Arne的建议执行:

fig, ax = plt.subplots(rows, cols) #makes a grid of subplots
或者将您的前两行写为:

fig, ax = plt.subplots(figsize=(15,10))
ax.axis('off')
这将在添加其他子地块之前删除整个子地块周围的轴