mirror of
https://github.com/boostorg/histogram.git
synced 2025-05-09 23:04:07 +00:00
21 lines
502 B
Python
21 lines
502 B
Python
import histogram as hg
|
|
import numpy as np
|
|
import matplotlib.pyplot as plt
|
|
|
|
h = hg.histogram(hg.regular_axis(10, -3, 3, uoflow=False),
|
|
hg.regular_axis(10, -3, 3, uoflow=False))
|
|
xy = np.random.randn(2000).reshape((1000, 2))
|
|
xy[:,1] *= 0.5
|
|
h.fill(xy)
|
|
|
|
bins = h.axis(0).bins
|
|
|
|
x = np.array(h.axis(0)) # axis instances behave like sequences
|
|
y = np.array(h.axis(1))
|
|
z = np.asarray(h) # creates a view (no copy involved)
|
|
|
|
plt.pcolor(x, y, z.T)
|
|
plt.xlabel("x")
|
|
plt.ylabel("y")
|
|
plt.show()
|