From: Jeffrey S. <jef...@gm...> - 2012-07-27 07:21:02
|
I am using 1.2.X and here is a minimalist example to see what happens: Link to figure of output: https://dl.dropbox.com/u/13534143/example.png Example: import numpy as np import matplotlib as mpl X, Y = np.meshgrid(arange(20),arange(20)) Z = np.arange(20*20) Z = Z.reshape(20,20) logNorm = mpl.colors.Normalize(vmin=0,vmax=200) fig = mpl.pyplot.figure(10) ax = fig.add_subplot(111) surf = ax.contourf(X,Y,Z, 100, cmap=matplotlib.cm.jet, norm = logNorm) cbar = fig.colorbar(surf, shrink=0.70, norm=logNorm) show() draw() On Fri, Jul 27, 2012 at 5:00 PM, Eric Firing <ef...@ha...> wrote: > On 2012/07/26 7:52 PM, Jeffrey Spencer wrote: > > I am trying to make a plot with a colorbar that has a reduced axis over > > which the colorbar is executed. > > > > This is set via passing in a norm to contourf: > > logNorm = colors.Normalize(vmax=0,vmin=-100) > > surf = ax.contourf(X,Y,logZ, map_scale, cmap=cm.jet, > norm=logNorm) > > > > The output of this will have the colorbar extend to the full range of > > the data and not limited by the norm set: > > > > cbar = fig.colorbar(surf, shrink=0.70, aspect=36, fraction=.15,pad=.03) > > > > so I assumed modifying by setting the norm like this would do the trick: > > > > cbar = fig.colorbar(surf, shrink=0.70, aspect=36, fraction=.15,pad=.03, > > norm=logNorm) > > > > This isn't what happens. norm has no effect. The norm is recognized but > > not passed to ColorbarBase is my guess from doing this instead to get > > the desired effect: > > > > axcb, _ = mpl.colorbar.make_axes_gridspec(ax, shrink=0.7) > > cbar = mpl.colorbar.ColorbarBase(axcb, cmap=cm.jet, > norm=logNorm) > > > > > > > > Is this a bug or any reason why the norm is not passed through if > > specified in colorbar?? > > Yes, there is a reason why it is not passed through; both the cmap and > the norm are taken from the mappable, so that the colorbar will actually > match the mappable. There may be a bug, but it is not immediately > obvious to me. Please provide a complete, minimal, self-contained > example that illustrates the problem, and specify what version of mpl > you are using. > > Eric > > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > |