examples for 2d histogramsΒΆ

import numpy as n
import dashi as d
import pylab as p

d.visual()

x = n.random.normal(2, 2, 1e5)
y = n.random.normal(-1, 3, 1e5)

h = d.factory.hist2d( (x,y), 100, labels=("x", "y"))

p.figure(figsize=(8,8))

p.subplot(221)
h.imshow()
cb = p.colorbar()
cb.set_label("bin count")

p.subplot(222)
h.imshow(log=1)
cb = p.colorbar()
cb.set_label("log10(bin count)")

p.subplot(223)
h.contour(filled=1)
cb = p.colorbar()
cb.set_label("bin count")

p.subplot(224)
h.contour(filled=0, levels=[.5,1,1.5], log=1,clabels=1)
cb = p.colorbar()
cb.set_label("log(bin count)")
p.xlim(-5,10)
p.ylim(-10,10)

(Source code)

"""
 use of 2d histograms for correlation studies
"""
import numpy as n
import dashi as d
import pylab as p

d.visual()

npoints = 1e5
y = n.random.uniform(0,10,npoints)
x = 2 * y + 3 + n.random.normal(0,2,npoints)

h = d.factory.hist2d((x,y),
                     (n.linspace(0,30,101), n.linspace(0,10,11)),
                     labels=("x","y")
                    )

p.figure(figsize=(9,9))
p.subplots_adjust(wspace=.25)

# simple imshow of bincontent array
p.subplot(221)
h.imshow()

# profile plots. project on dimension 1 ("y")
p.subplot(222)
scatterpoints = d.histfuncs.h2profile(h,dim=1)
scatterpoints.scatter()

# stacked 1d histograms plots
# keeping the overall shape of the projected distribution
p.subplot(223)
h.stack1d()

# normalizing each bin to 1 to emphasize relative contributions
p.subplot(224)
h.stack1d(boxify=1)

(Source code)