Histogram
Builder for creating histograms. Bins a 1-D dataset and renders each bin as a vertical bar. The bin boundaries are computed from the data range (or an explicit range) and the requested bin count.Constructor
Create a histogram with default settings.Defaults:
- 10 bins
- Color:
"black" - No normalization
- No range (must be set explicitly)
Data Methods
Into<f64>. Values outside the active range are silently ignored.Important: with_range() must also be called. Without an explicit range, Layout::auto_from_plots cannot determine the axis extent and the chart will be empty.Example:10). The bin edges span from range.min to range.max. Choose a value that balances resolution against noise for your sample size.Layout::auto_from_plots to work. Without an explicit range, bounds() returns None and Layout::auto_from_plots cannot determine the axis extent, resulting in an empty chart.Typically pass the data min/max. For overlapping histograms, pass the same combined range to both so their x-axes align. Values outside the range are silently ignored during binning.Example:Styling Methods
"steelblue", "#4682b4").For overlapping histograms, use an 8-digit hex color with an alpha channel (#RRGGBBAA) so bars from different series show through:Example:1.0. This is a peak-normalization — not a probability density. The y-axis represents relative frequency (tallest bin = 1), not counts or probability per unit width.Legend Methods
Vec<Plot> has a label.