[SciPy-Dev] 2D histogram: request for plotting variable bin size

Frank Breitling fbreitling@aip...
Sat Feb 2 03:53:28 CST 2013


Hi,

 From the matplotlib developers it was pointed out, that there is a 
NonUniformImage which might be suite for representing interpolated 
variable bin size 2D histograms 
(https://github.com/matplotlib/matplotlib/issues/1729#issuecomment-13014723). 
There even exists an example 
(http://matplotlib.org/examples/pylab_examples/image_nonuniform.html) 
but it is very isolated and therefore not well known.
It would be very useful to explain its usage or at least link to it in 
the histogram2d example at 
http://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram2d.html.

In addition a pcolor example (attached below) shouldn't be missing. Even 
though it is slow and can't do interpolation, it can at least do a 
correct representation for academic purposes.

Can anybody do that or would you like me to do that myself?

Frank

---

import numpy as np, matplotlib.pyplot as plt

x=[2]
y=[0]
xedges=[0,1,3]
yedges=[0,1]

H, yedges, xedges = np.histogram2d(y,x, bins=(yedges,xedges))
extent = [xedges[0], xedges[-1], yedges[-1], yedges[0]]
X,Y = np.meshgrid(xedges, yedges)
plt.pcolor(X, Y, H)
plt.colorbar()
plt.show()



More information about the SciPy-Dev mailing list