On Mon, Feb 22, 2010 at 3:42 PM, Jan Strube <curious...@gmail.com> wrote: > Hi John, > the attachment may not make it to the list. However, please run the modified > test.py that I have attached. > It requires the attached input file. > Then change it to read the original input file. > In my case: > The broken case:
OK, at least now we are running the sample example :-) The problem is that the LogFormatter has a default which is "decadeOnly=True" and in the first case which "worked" three of the tick locations coincidentally came down on decades (0, 1, 2 -> 1, 10, 100). In the case you were working with, only one of the ticks mapped to the decade. So for this case we want a locator that returns integers 0,1,2... that will then get mapped via Eric's custom formatter to the 10^i formats. Unfortunately, there is no easy way to set the locator for the colorbar. An easy workaround *for this case* is to simply set the tick locations cb = plt.colorbar(format=LogFormatterHB(), ticks=[0,1,2]) but in general you may not know the decade span that you need. It does all feel a bit kludgy. The problem as you noted in one of your earlier posts is that the data is log scaled before being passed into the PolyCollection and the fact that it is log scaled is then lost to the colorbar. It seems everything would fit together more naturally if we passed in raw scalar data to the PolyCollection and set the norm to be colors.LogNorm, and then also set norm=colors.LogNorm on the colorbar I tried: polycol = plt.hexbin(data['jetMomentum'][cut] / 1000, data['deltaR'][cut],gridsize=50, norm=colors.LogNorm()) cb = plt.colorbar(norm=colors.LogNorm()) but this appears to be broken: msie...@pinchiepie:Downloads> python test.py Traceback (most recent call last): File "test.py", line 29, in <module> cb = plt.colorbar() File "/home/msierig/dev/lib/python2.6/site-packages/matplotlib/pyplot.py", line 1356, in colorbar ret = gcf().colorbar(mappable, cax = cax, ax=ax, **kw) File "/home/msierig/dev/lib/python2.6/site-packages/matplotlib/figure.py", line 1103, in colorbar cb = cbar.Colorbar(cax, mappable, **kw) File "/home/msierig/dev/lib/python2.6/site-packages/matplotlib/colorbar.py", line 690, in __init__ ColorbarBase.__init__(self, ax, **kw) File "/home/msierig/dev/lib/python2.6/site-packages/matplotlib/colorbar.py", line 242, in __init__ self.draw_all() File "/home/msierig/dev/lib/python2.6/site-packages/matplotlib/colorbar.py", line 260, in draw_all self._config_axes(X, Y) File "/home/msierig/dev/lib/python2.6/site-packages/matplotlib/colorbar.py", line 332, in _config_axes self.update_ticks() File "/home/msierig/dev/lib/python2.6/site-packages/matplotlib/colorbar.py", line 271, in update_ticks ticks, ticklabels, offset_string = self._ticker() File "/home/msierig/dev/lib/python2.6/site-packages/matplotlib/colorbar.py", line 458, in _ticker b = np.array(locator()) File "/home/msierig/dev/lib/python2.6/site-packages/matplotlib/ticker.py", line 1173, in __call__ vmin = self.axis.get_minpos() ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users