|
From: Jeffrey S. <jef...@gm...> - 2012-07-29 15:14:04
|
Eric, Normalize appears to be working correctly and as you stated above but when passed into contourf appears to have inconsistent results not following the docstring by allowing the value to change. Quick examples: X, Y = meshgrid(arange(20),arange(20)) Z = arange(20*20) Z = Z.reshape(20,20) norm = colors.Normalize(vmin=200,vmax=None) print norm.vmin fig = figure(10) ax = fig.add_subplot(111) surf = ax.contourf(X,Y,Z, 100, cmap=matplotlib.cm.jet, norm = norm) This vmin has no effect where if you pass in: X, Y = meshgrid(arange(20),arange(20)) Z = arange(20*20) Z = Z.reshape(20,20) norm = colors.Normalize(vmin=200,vmax=Z.max()) print norm.vmin fig = figure(10) ax = fig.add_subplot(111) surf = ax.contourf(X,Y,Z, 100, cmap=matplotlib.cm.jet, norm = norm) it has the desired effect. Let me know if this is correct or I'm missing something here. Cheers, Jeff On Mon, Jul 30, 2012 at 12:32 AM, Eric Firing <ef...@ha...> wrote: > On 2012/07/28 10:17 PM, Jeffrey Spencer wrote: > >> Think I figured out an actual bug in the function: colors.Normalize(). >> >> The behavior states that if vmin or vmax is passed in as None it should >> take the minimum or maximum value respectively. >> >> If only one value is passed into the function, both values are >> overwritten to the min and max instead of just the one that is not >> passed in. So the only case where it sets the limits is if both vmin and >> vmax are passed to the function. Is this the desired behavior because >> from the docstring it seems this is incorrect. >> >> Cheers, >> Jeff >> >> >> > Jeff, > > I don't see it, so you need to provide an actual example. Here is what > happens (in ipython --pylab) when I try to reproduce what it sounds like > you are describing: > > In [2]: norm = Normalize(vmax=10) > > In [3]: norm([-10, 10, 20]) > Out[3]: > masked_array(data = [ 0. 1. 1.5], > mask = False, > fill_value = 1e+20) > > > In [4]: norm.vmin > Out[4]: -10.0 > > In [5]: norm.vmax > Out[5]: 10 > > This behavior is as described in the docstring. > > The one potentially confusing aspect that I see at the moment is that the > Normalize class does not distinguish between explicit vmin, vmax, and the > values that it calculates via its autoscale_None method when called. As > soon as a None is replaced by an actual value, whether by being set > explicitly or by autoscaling, the replacement is permanent. Perhaps this > should be made explicit in the docstring. The docstrings could be > re-arranged to clarify the roles of the class initializer and its __call__ > method. > > Eric > > |