I want to populate an array and then show it like an image. I want to set two parameters for each array element: a “color value” and a “transparency value”.
I am using imshow from matplotlib, but I am open to other solutions.
I have tried with something like this, where ca_map is a MxN array.
ca_map = np.array(ca_map)
palette = cm.jet
palette.set_under('w', 1.0)
plt.axis('off')
plt.imshow(ca_map, cmap=palette, norm=colors.Normalize(vmin=0, clip=False), interpolation='sinc')
plt.show()
Thanks in advance.
The docs ( http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.imshow ) say that you can pass an MxNx4 array of RGBA values to imshow. So, assuming ca_map is MxNx3, you could do something like:
Or if ca_map is MxN, then: