我有一个关于matplotlib和colorbar的问题。我的项目里有很多热图。假设我的数组是两个数组除以的结果。你知道吗
例如(为了使问题形象化):
import numpy as np
import matplotlib as plt
array_1 = A/B # A and B are 2 arrays, same shape etc ..
array_2 = C/D # C and D are 2 arrays, same shape etc ..
##################################
# Representation with matplotlib #
##################################
fig_step1 = ax1.imshow(array_1, interpolation='nearest')
fig1.colorbar(fig_step1,ax=ax1)
ax1.set_xlabel("X (arcmin)")
ax1.set_ylabel("Y (arcmin)")
ax1.set_title("array number 1")
fig_step2 = ax2.imshow(array_2, interpolation='nearest')
fig1.colorbar(fig_step2,ax=ax2)
ax2.set_xlabel("X (arcmin)")
ax2.set_ylabel("Y (arcmin)")
ax2.set_title("array number 2")
==>;但是,即使除法适用于99%的数据,并且我从数组1和数组2中得到值1的平均值。有时我有几个点(1%),例如A/B之间的结果是1000000,并使我的色条错误。你知道吗
==>;如何使用色条在热图中只打印[0;1]之间的点?也就是说,要有一个动态的色条?你知道吗
我为我的英语很差道歉:/
谢谢你!你知道吗
我想有两种解决方案:要么设置
vmin
和vmax
的参数imshow
,要么屏蔽数组中的无效值。你知道吗结果是:
或者,如果要屏蔽无效值(假设所有大于1的值都无效):
结果是:
相关问题 更多 >
编程相关推荐