def __call__(self, value, clip=None): if clip is None: clip = self.clip if cbook.iterable(value): vtype = 'array' val = ma.asarray(value).astype(npy.float) else: vtype = 'scalar' val = ma.array([value]).astype(npy.float) self.autoscale_None(val) vmin, vmax = self.vmin, self.vmax if vmin > vmax: raise ValueError("minvalue must be less than or equal to maxvalue") elif vmin<=0: raise ValueError("values must all be positive") elif vmin==vmax: return 0.0 * val else: if clip: mask = ma.getmask(val) val = ma.array(npy.clip(val.filled(vmax), vmin, vmax), mask=mask) result = (ma.log(val)-npy.log(vmin))/(npy.log(vmax)-npy.log(vmin)) if vtype == 'scalar': result = result[0] return result
def __call__(self, value, clip=None): if clip is None: clip = self.clip if cbook.iterable(value): vtype = 'array' val = ma.asarray(value).astype(npy.float) else: vtype = 'scalar' val = ma.array([value]).astype(npy.float) self.autoscale_None(val) vmin, vmax = self.vmin, self.vmax if vmin > vmax: raise ValueError("minvalue must be less than or equal to maxvalue") elif vmin <= 0: raise ValueError("values must all be positive") elif vmin == vmax: return 0.0 * val else: if clip: mask = ma.getmask(val) val = ma.array(npy.clip(val.filled(vmax), vmin, vmax), mask=mask) result = (ma.log(val) - npy.log(vmin)) / (npy.log(vmax) - npy.log(vmin)) if vtype == 'scalar': result = result[0] return result
Z1 = bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0) Z2 = bivariate_normal(X, Y, 1.5, 0.5, 1, 1) Z = 10 * (Z1 - Z2) # interior badmask doesn't work yet for filled contours if test_masking: badmask = zeros(shape(Z)) badmask[5,5] = 1 badmask[5,6] = 1 Z[5,5] = 0 Z[5,6] = 0 badmask[0,0] = 1 Z[0,0] = 0 Z = ma.array(Z, mask=badmask) # We are using automatic selection of contour levels; # this is usually not such a good idea, because they don't # occur on nice boundaries, but we do it here for purposes # of illustration. CS = contourf(X, Y, Z, 10, # [-1, -0.1, 0, 0.1], #alpha=0.5, cmap=cm.bone, origin=origin) # Note that in the following, we explicitly pass in a subset of # the contour levels used for the filled contours. Alternatively, # We could pass in additional levels to provide extra resolution. CS2 = contour(X, Y, Z, CS.levels[::2],