Hist2d#
- class atompy.Hist2d(values, xedges, yedges, title='', xlabel='', ylabel='', zlabel='')[source]#
A histogram class providing basic 2D-histogram methods.
- Parameters:
- valuesarray_like, shape (m, n)
The values of the histogram given as a 2D-array, where
values[m, n]corresponds to the bin whose edges are given by [xedges[m],xedges[m+1]] and [yedges[n],yedges[n+1]].- xedgesarray_like, shape (m+1,)
The x-edges of the histogram.
- yedgesarray_like, shape (n+1,)
The y-edges of the histogram.
- title
str, default “” Optional title of the histogram.
May be used in
plot().- xlabel
str, default “” Optional xlabel of the histogram.
May be used in
plot().- ylabel
str, default “” Optional ylabel of the histogram.
May be used in
plot().- zlabel
str, default “” Optional zlabel of the histogram.
May be used in
plot().
- Attributes:
valuesndarray, shape(m, n)The histogram values.
Hndarray, shape(m, n)Alias for
Hist2d.valuesxedgesndarray, shape(m+1,)The histogram x-edges.
yedgesndarray, shape(n+1,)The histogram y-edges.
xcentersndarray, shape(m,)The centers of the histogram x-edges.
ycentersndarray, shape(n,)The centers of the histogram y-edges.
xbinsintThe number of x bins.
ybinsintThe number of y bins.
nbins(int,int)(nxbins, nybins)
xlim(float,float)The x-range of the histogram.
ylim(float,float)The y-range of the histogram.
limits((float,float), (float,float))(xlim, ylim)
titlestrHistogram title.
xlabelstrHistogram xlabel.
ylabelstrHistogram ylabel.
zlabelstrHistogram zlabel.
labels_dictdictDictionary of the title and labels.
Methods
binareas()Compute the area of each 2D bin in the histogram.
binsizes()Compute the binsizes along x and y.
Compute the widths of the bins along the x-axis.
Compute the widths of the bins along the y-axis.
copy()Return a copy of the histogram.
Prepare the histogram data for plotting with
matplotlib.pyplot.pcolormesh.from_centers(xcenters, ycenters, values[, ...])Initiate a
Hist2dfrom centers (rather than edges).from_image(image[, extents, title, xlabel, ...])Create a
Hist2dfrom a 2D image.from_root(fname, hname[, title, xlabel, ...])from_txt(fname, *[, iteration_order, ...])Initiate a
Hist2dfrom a text file.Return the integral of the histogram.
keep([xlower, xupper, ylower, yupper, ...])Return a new histogram with only bins within the specified (x, y) range.
max()Returns the maximum value of the histogram.
min()Returns the minimum value of the histogram.
Normalize each column to their integral.
Normalize each column to their maximum.
Normalize each column to their sum.
norm_diff(other)Return the normalized difference between two histograms.
Normalize each row to their integral.
Normalize each row to their maximum.
Normalize each row to their sum.
Normalize histogram to it's integral.
Normalize histogram to it's maximum.
Normalize histogram to it's maximum.
Normalize values to the number of x bins.
Normalize values to the number of y bins.
plot([ax, fname, xlabel, ylabel, zlabel, ...])Plot the 2D histogram using
matplotlib.pyplot.pcolormesh.profile_along_x([option])Get the x-profile.
profile_along_y([option])Get the y-profile.
Project histogram onto its x-axis.
Project histogram onto its x-axis.
rebin_x(fac)Rebin the histogram along the x-axis by an integer factor.
rebin_y(fac)Rebin the histogram along the y-axis by an integer factor.
remove([xlower, xupper, ylower, yupper, setval])Return a new histogram with bins within the specified (x, y) range set to setval.
Replace zeros with NaN, removing them from colormaps.
save_to_file(fname, **savetxt_kwargs)Save the histogram to a file.
sum()Return the sum of all bins of the histogram.