Python 删除gridspec matlibplot的XTick和Ytick
我正在尝试从已设置的gridspec绘图中删除所有标签和x/Ytick 下图是我当前的输出,但我需要删除所有的标签以及x记号和y记号,所以它们基本上是空框。我只是因为某些原因不能做 这是我在这里使用的代码Python 删除gridspec matlibplot的XTick和Ytick,python,matplotlib,Python,Matplotlib,我正在尝试从已设置的gridspec绘图中删除所有标签和x/Ytick 下图是我当前的输出,但我需要删除所有的标签以及x记号和y记号,所以它们基本上是空框。我只是因为某些原因不能做 这是我在这里使用的代码 fig = plt.figure() gs = fig.add_gridspec(2, 9) # Query image ax1 = fig.add_subplot(gs[:, 0]) #Positive image ax2 = fig.add_subplot(gs[0, 1]) ax3
fig = plt.figure()
gs = fig.add_gridspec(2, 9)
# Query image
ax1 = fig.add_subplot(gs[:, 0])
#Positive image
ax2 = fig.add_subplot(gs[0, 1])
ax3 = fig.add_subplot(gs[0, 2])
ax4 = fig.add_subplot(gs[0, 3])
ax5 = fig.add_subplot(gs[0, 4])
# Negative images
ax6 = fig.add_subplot(gs[1, 1])
ax7 = fig.add_subplot(gs[1, 2])
ax8 = fig.add_subplot(gs[1, 3])
ax9 = fig.add_subplot(gs[1, 4])
# all_axes = fig.get_axes()
# # show only the outside spines
# for ax in all_axes:
# for sp in ax.spines.values():
# sp.set_visible(False)
# if ax.is_first_row():
# ax.spines['top'].set_visible(True)
# if ax.is_last_row():
# ax.spines['bottom'].set_visible(True)
# if ax.is_first_col():
# ax.spines['left'].set_visible(True)
# if ax.is_last_col():
# ax.spines['right'].set_visible(True)
plt.tick_params(axis='x',
which='both',
bottom=False,
top = False,
labelbottom=False)
#plt.axis('off')
#plt.xticks([], [])
#plt.xticks.remove
#plt.yticks.remove
plt.show()
我试过几种方法,但还是不好 应该使用
matplotlib.axes.axes.tick_-params()
而不是matplotlib.pyplot.tick_-params()
。后者仅适用于“当前”,在本例中为最近创建的轴实例-前者允许您将勾号参数应用于任何轴实例。考虑:
图中ax的获取轴()
ax.勾选参数(底部=假,标签底部=假,左侧=假,标签左侧=假)
那会产生什么
可能值得查看
sharex
和sharey
选项,以添加子批次
。