from_centers#

classmethod Hist2d.from_centers(xcenters, ycenters, values, xmin=None, xmax=None, ymin=None, ymax=None, title='', xlabel='', ylabel='', zlabel='')[source]#

Initiate a Hist2d from centers (rather than edges).

Parameters:
xcentersArrayLike

The x-coordinates of the bin centers.

ycentersArrayLike

The y-coordinates of the bin centers.

valuesArrayLike

The values associated with each bin.

xmin/xmax/ymin/ymaxfloat, optional

The lower (upper) x (y) bound to use when converting centers to edges. Either the lower or the upper bound must be provided if the bins have unequal size. Unnecessary for equally sized bins.

Returns:
Hist2d

A new Hist2d instance.

Examples

>>> xcenters = [0.5, 1.5, 2.5]
>>> ycenters = [10.0, 20.0]
>>> values = [[1, 2], [3, 4], [5, 6]]
>>> hist = Hist2d.from_centers(xcenters, ycenters, values)
>>> print(hist.xedges)
[0., 1., 2., 3.]
>>> print(hist.yedges)
[5., 15., 25.]
>>> print(hist.values)
[[1, 2], [3, 4], [5, 6]]
>>> xcenters = [0.5, 1.0, 2.0]
>>> ycenters = [10.0, 20.0]
>>> values = [[1, 2], [3, 4], [5, 6]]
>>> hist = Hist2d.from_centers(xcenters, ycenters, values, xmin=0.0)
>>> print(hist.xedges)
[0.0, 0.75, 1.5, 2.5]