Hi John,
thanks for keeping at it. I have updated from svn
But this script
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.ticker import LogFormatter
from matplotlib import colors
class LogFormatterHB(LogFormatter):
def __call__(self, v, pos=None):
vv = self._base ** v
print vv
return LogFormatter.__call__(self, vv, pos)
data = np.load('deltaR_parton_jet_109370.npz')
ptcut = np.logical_and(data['jetMomentum'] < 300000, data['jetMomentum']>0)
deltaRCut = data['deltaR']>0
cut = np.logical_and(ptcut, deltaRCut)
fig = plt.figure()
polycol = plt.hexbin(data['jetMomentum'][cut] / 1000, data['deltaR'][cut],
gridsize=50, norm=colors.LogNorm())
plt.title('deltaR between parton(eta<2.5) and jet(eta<2.5)')
plt.xlabel('jet pt (GeV)')
plt.ylabel('deltaR')
cb = plt.colorbar(norm=polycol.norm)
cb.set_label('# entries')
fig.savefig('hexbin_demo.png', dpi=100)
#plt.show()
gives me an error:
> python test.py
Traceback (most recent call last):
File "test.py", line 24, in <module>
cb = plt.colorbar(norm=polycol.norm)
File
"/Users/Jan/PYTHON/lib/python2.6/site-packages/matplotlib-1.0.svn_r8037-py2.6-macosx-10.6-universal.egg/matplotlib/pyplot.py",
line 1356, in colorbar
ret = gcf().colorbar(mappable, cax = cax, ax=ax, **kw)
File
"/Users/Jan/PYTHON/lib/python2.6/site-packages/matplotlib-1.0.svn_r8037-py2.6-macosx-10.6-universal.egg/matplotlib/figure.py",
line 1104, in colorbar
cb = cbar.Colorbar(cax, mappable, **kw)
File
"/Users/Jan/PYTHON/lib/python2.6/site-packages/matplotlib-1.0.svn_r8037-py2.6-macosx-10.6-universal.egg/matplotlib/colorbar.py",
line 649, in __init__
ColorbarBase.__init__(self, ax, **kw)
File
"/Users/Jan/PYTHON/lib/python2.6/site-packages/matplotlib-1.0.svn_r8037-py2.6-macosx-10.6-universal.egg/matplotlib/colorbar.py",
line 240, in __init__
self.draw_all()
File
"/Users/Jan/PYTHON/lib/python2.6/site-packages/matplotlib-1.0.svn_r8037-py2.6-macosx-10.6-universal.egg/matplotlib/colorbar.py",
line 251, in draw_all
self._config_axes(X, Y)
File
"/Users/Jan/PYTHON/lib/python2.6/site-packages/matplotlib-1.0.svn_r8037-py2.6-macosx-10.6-universal.egg/matplotlib/colorbar.py",
line 278, in _config_axes
ticks, ticklabels, offset_string = self._ticker()
File
"/Users/Jan/PYTHON/lib/python2.6/site-packages/matplotlib-1.0.svn_r8037-py2.6-macosx-10.6-universal.egg/matplotlib/colorbar.py",
line 417, in _ticker
b = np.array(locator())
File
"/Users/Jan/PYTHON/lib/python2.6/site-packages/matplotlib-1.0.svn_r8037-py2.6-macosx-10.6-universal.egg/matplotlib/ticker.py",
line 1085, in __call__
vmin = self.axis.get_minpos()
AttributeError: DummyAxis instance has no attribute 'get_minpos'
Cheers,
Jan
On Tue, Feb 23, 2010 at 12:26 AM, John Hunter <jdh2...@gmail.com> wrote:
> On Mon, Feb 22, 2010 at 4:33 PM, John Hunter <jdh2...@gmail.com> wrote:
> > 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:
>
> I committed some changes to support this -- the following now works:
>
> polycol = plt.hexbin(data['jetMomentum'][cut] / 1000,
> data['deltaR'][cut],gridsize=50, norm=colors.LogNorm())
>
> cb = plt.colorbar(norm=polycol.norm)
>
> Eric - I was surprised the colorbar does not use the mappable norm by
> default (if passed norm=None). Instead it uses ::
>
> norm = colors.Normalize()
>
> is this a feature?
>
> JDH
>
------------------------------------------------------------------------------
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