|
From: Jeffrey S. <jef...@gm...> - 2012-07-27 07:02:12
|
Further after doing a little digging the code in matplotlib.colorbar.Colorbar looks correct to me but doesn't work correctly. It essentially ignores the norm value because always sets the norm to the norm for the contour plot (eg. mappable.norm) which this is the same norm with vmin and vmax values I want to use anyway. It seems as though somehow instead it uses the vmin and vmax not from the norm but from the actual data. So from the code below it would use vmin and vmax from the mappable object (eg. surf) which are (-152,0). It won't use surf.norm vmin and vmax values which are desired (-100,0). I couldn't find where this mistake occurs because looked right to me from prodding around but let me know. ____________________________________________ Jeff Spencer Department of Electrical and Electronic Engineering The University of Melbourne jef...@gm... On Fri, Jul 27, 2012 at 3:52 PM, Jeffrey Spencer <jef...@gm...>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?? > |