Matplotlib Save imshow array

I was wondering if it were at all possible to save the array of an imshow function? What do I mean by this?

Well, I have a 2d array with unique values. I would like to see that represented in colour, so I naturally would use the imshow function. I understand that the imshow function applies a colormap to my array and then displays that. I would like to be able to get the array that matplotlib uses to show my original 2d array in colour. Can this be done?


You can actually just get the color maping with out imshow

data_ = (data - np.min(data))/ (np.max(data) - np.min(data))
my_cmap = matplotlib.cm.get_cmap('gray') # or what ever color map you want
color_array = my_cmap(data_)

color_array with be an array of shape data.shape + (4,) , that is MxNx4 with the 4 being (r,g,b,a). Your data needs to be scaled to be in the range [0,1] .

链接地址: http://www.djcxy.com/p/48372.html

上一篇: 循环中连续渲染numpy数组

下一篇: Matplotlib保存imshow数组