如何在将行标题保留在ImageGrid中的同时删除刻度线和数字?
grid[j].axis("off")
删除标签输入,地面真相,预测,而
grid[j].set_xticklabels([])
grid[j].set_yticklabels([])
仅删除数字,而不删除轴上的破折号。我浏览了https://matplotlib.org/3.1.1/api/_as_gen/mpl_toolkits.axes_grid1.axes_grid.ImageGrid.html,但似乎没有刻度线。
for idx in range(0,1):
fig = plt.figure(idx, (15, 10))
grid = ImageGrid(fig, 111, nrows_ncols=(3, 10), axes_pad=0.1)
grid[0].set_ylabel("Input",rotation=0)
grid[10].set_ylabel("Ground Truth",rotation=0)
grid[20].set_ylabel("Variational ConvLSTM",rotation=0)
for j in range(10):
#grid[j].set_xticklabels([])
#grid[j].set_yticklabels([])
#grid[j].axis("off") This removes the title
grid[j].imshow(x_true[idx,j], cmap="gray")
grid[j+10].imshow(x_true[idx,j+10], cmap="gray")
grid[j+20].imshow(x_temp[idx,j], cmap="gray")
这是我当前的输出。理想情况下,它应该没有刻度(破折号)并且没有数字。
答案 0 :(得分:0)
简单的方法是先设置share_all = True
grid[0].get_yaxis().set_ticks([])
grid[0].get_xaxis().set_ticks([])
因此所有刻度都被禁用
for idx in range(0,1):
fig = plt.figure(idx, (15, 10))
grid = ImageGrid(fig, 111, nrows_ncols=(3, 10), axes_pad=0.1, share_all=True)
grid[0].get_yaxis().set_ticks([])
grid[0].get_xaxis().set_ticks([])
# labels
grid[0].set_ylabel("Input",rotation=0)
grid[10].set_ylabel("Ground Truth",rotation=0)
grid[20].set_ylabel("Prediction",rotation=0)
for j in range(10):
#grid[j].set_xticklabels([])
#grid[j].set_yticklabels([])
#grid[j].get_yaxis().set_ticks([])
#grid[j].get_xaxis().set_ticks([])
#grid[j].axis("off")
grid[j].imshow(x_true[idx,j], cmap="gray")
grid[j+10].imshow(x_true[idx,j+10], cmap="gray")
grid[j+20].imshow(x_temp[idx,j], cmap="gray")