Hist1d#
- class atompy.Hist1d(values, edges, title='', xlabel='', ylabel='')[source]#
A histogram class providing basic histogram methods.
Tip
Histogram your data using
numpy.histogram(), then wrap the results inHist1d:hist = ap.Hist1d(*np.histogram(data))
- Parameters:
- valuesarray_like
The histogram values, e.g., counts.
- edgesarray_like
The edges of the histogram bins. Note that
len(values) = len(edges) + 1Note
If you want to initialize a
Hist1dfrom centers instead of edges, useHist1d.from_centers().- title
str, default “” Optional title of the histogram.
- xlabel
str, default “” Optional x-label of the histogram.
- ylabel
str, default “” Optional y-label of the histogram.
- Attributes:
edgesndarrayEdges of the histogram’s bins.
bin_edgesndarrayAlias for
Hist1d.edgesvaluesndarrayHistogram’s values (e.g., counts).
histndarrayAlias for
Hist1d.valuescentersndarrayCenters of the histogram’s bins.
limits(float,float)Limits of the histogram’s edges.
nbinsintNumber of bins.
labels_dictdictA dictionary of the histogram’s title, xlabel and ylabel.
Methods
binsizes()Return the widths of all bins.
convert_cosine_to_angles([full_range])Convert edges which represent cosine(angle) to angle.
copy()Return a copy of the histogram.
for_bar()Return arrays appropriate for plotting with
plt.bar.for_plot()Return arrays appropriate for plotting with
plt.plot.for_step([extent_to])Return arrays appropriate for plotting with
plt.step.from_centers(values, centers[, lower, ...])Initiate a
Hist1dinstance from values and bin-centers.from_root(fname, hname[, title, xlabel, ylabel])from_txt(fname[, data_layout, idx_centers, ...])Initiate a
Hist1dfrom a text file.Return the integral of the histogram.
keep(lower, upper[, squeeze, setval])Keep every entry of the histogram in-between lower and upper
max()Return the maximum value of the histogram.
min()Return the minimum value of the histogram.
norm_diff(other)Return the normalized difference between two histograms.
Return the histogram normalized to
Hist1d.integrate().Return the histogram normalized to
Hist1d.max().Return the histogram normalized to
Hist1d.sum().pad_with(value)Extent histogram left and right with value.
plot([ax, fname, xlabel, ylabel, title, ...])Plot the 1D histogram using
matplotlib.pyplot.plot.plot_step([ax, fname, xlabel, ylabel, ...])Plot the 1D histogram using
matplotlib.pyplot.plot.rebin(factor)Rebin histogram.
remove(lower, upper[, setval])Remove every entry of the histogram in-between lower and upper
sum()Return the sum of the histogram's values.