This way is easy and works:
JavaScript
x
3
1
plt.imshow(im)
2
plt.colorbar()
3
But when it’s like this:
JavaScript
1
3
1
f,ax = plt.subplots(3,1)
2
ax[2].imshow(im)
3
How do I get the colorbar on that axis? I don’t need anything fancy, just the defaults.
Advertisement
Answer
Pass the respective image and axes handles into fig.colorbar
:
JavaScript
1
5
1
fig, axs = plt.subplots(3, 1)
2
3
im2 = axs[2].imshow(im)
4
fig.colorbar(im2, ax=axs[2])
5