From: Phillip M. F. <pfe...@ve...> - 2009-09-30 20:18:22
|
Hello Eric- I've looked at the code in colors.py. I think that I'm starting to understand what's going on, but I'm unclear about a few things. In particular: - Why do we need to define both forward and reverse transformations? Shouldn't the forward transformation be sufficient? - I don't follow what the snippet of code below is doing: if cbook.iterable(value): vtype = 'array' val = ma.asarray(value).astype(np.float) else: vtype = 'scalar' val = ma.array([value]).astype(np.float) - In some cases I'd like to map the data values to discrete output values, e.g., values below x_0 map to 0 (which the colormap in turn maps to red), values between x_0 and x_1 map to 0.5 (which maps to yellow), and values greater than x_1 map to 1 (which maps to green). Such a function does not have a mathematical inverse because it is a many to one mapping. How does one handle this situation? The ability to pass in an ordinary function (or a pair of functions if the inverse is really necessary) would be a great benefit. Thanks! Phillip Eric Firing wrote: > Dr. Phillip M. Feldman wrote: >> I'd like to generate a scatter plot in which symbols are colored using a >> specified colormap, with a specified mapping from the range of the >> data to >> the [0,1] colormap interval. I thought at first that one could use >> the norm >> argument to specify a function that would perform this mapping, but from >> closer reading of the documentation (and experimentation) it seems as >> though >> one cannot do this. Is there another mechanism for doing this? (I could >> remap the data itself before plotting it, but this is unacceptable >> because >> the colorbar tic lables would then take values in [0,1] rather than >> values >> from the range of the data). >> > > I don't understand--what you say you want to do is exactly what the > norm is designed for. Maybe the problem is that you can't pass in a > simple function--you need to subclass colors.Normalize. An example is > colors.LogNorm. > > It looks like what we need is a FuncNorm, which would be initialized > with two functions, the forward and inverse transformation functions, > each taking vmin, vmax, and a val. > > Eric > |