Python matplotlib.colors 模块,Nonorm() 实例源码
我们从Python开源项目中,提取了以下6个代码示例,用于说明如何使用matplotlib.colors.Nonorm()。
@H_502_19@
def _locate(self, x):
'''
Given a set of color data values,return their
corresponding colorbar data coordinates.
'''
if isinstance(self.norm, (colors.Nonorm, colors.Boundarynorm)):
b = self._boundaries
xn = x
else:
# Do calculations using normalized coordinates so
# as to make the interpolation more accurate.
b = self.norm(self._boundaries, clip=False).filled()
xn = self.norm(x, clip=False).filled()
# The rest is linear interpolation with extrapolation at ends.
y = self._y
N = len(b)
ii = np.searchsorted(b, xn)
i0 = ii - 1
itop = (ii == N)
ibot = (ii == 0)
i0[itop] -= 1
ii[itop] -= 1
i0[ibot] += 1
ii[ibot] += 1
#db = b[ii] - b[i0]
db = np.take(b, ii) - np.take(b, i0)
#dy = y[ii] - y[i0]
dy = np.take(y, ii) - np.take(y, i0)
z = np.take(y, i0) + (xn - np.take(b, i0)) * dy / db
return z