Matplotlib保存imshow阵列 [英] Matplotlib Save imshow array

查看:246
本文介绍了Matplotlib保存imshow阵列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在想,如果它是在所有可能保存imshow功能的阵列?什么意思呢?

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

嗯,我有一个二维数组具有独特的价值。我希望看到psented的颜色重新$ P $,所以我自然会使用imshow函数。据我所知,imshow函数应用一个颜色映射到我的数组,然后显示。我希望能够得到这matplotlib使用,以显示我原来的二维数组中颜色的数组。可以这样做?

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?

推荐答案

您可以真正地得到的颜色与马平了 imshow

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 与是形状数组 data.shape +(4),即MxNx4与4存在(R,G,B,A)。需要你的数据来进行缩放以在范围 [0,1]

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].

这篇关于Matplotlib保存imshow阵列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆