I have the following code:
plt.figure(figsize=(15, 20))
min_v = np.min(net_l0)
max_v = np.max(net_l0)
for i in range(8):
for j in range(4):
num = i*4 + j
plt.subplot(8,4, num+1)
w_filt = net_l0[num, :3]
w_filt = w_filt.swapaxes(0, 1).swapaxes(1, 2)
imgplot = plt.imshow(w_filt, vmin=min_v, vmax=max_v, interpolation='none')
imgplot.set_cmap('gray')
plt.colorbar()
plt.show()
For some reason, however, the colormap is not applied to the image only to the colorbar? I tried and adding the cmap keyword to the imshow, but still did not work. Any ideas what I'm doing wrong?
Make sure the array you are displaying is actually 2-dimensional. If you (for example) load a grayscale image that actually has three channels, then imshow will happily show you the image, but it won't apply the colormap to it. The picture is "already color", after all.
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