How can I remove the ticks and numbers while keeping the row-title in ImageGrid?
grid[j].axis("off")
Removes the label Input, Ground Truth, Prediction whereas
grid[j].set_xticklabels([])
grid[j].set_yticklabels([])
only removes the numbers but not the dashes on the axis. I looked through https://matplotlib.org/3.1.1/api/_as_gen/mpl_toolkits.axes_grid1.axes_grid.ImageGrid.html but it doesn't seem to have an option to have no 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)
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")
Here is the output I currently have. It should ideally have no ticks (the dashes) and no numbers.
Simple way to do it is to set share_all = True
then
grid[0].get_yaxis().set_ticks([])
grid[0].get_xaxis().set_ticks([])
so all the ticks get disabled
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")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With