|
From: Eric F. <ef...@ha...> - 2012-07-27 07:00:24
|
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 |