pub struct HistArtist {
pub data: Series,
pub bins: usize,
pub bin_edges: Vec<f64>,
pub counts: Vec<f64>,
pub color: Color,
pub label: Option<String>,
pub alpha: f64,
pub density: bool,
}Expand description
A histogram showing the frequency distribution of a single data series.
The raw data is retained in data, but the binning results (bin_edges
and counts) are expected to be pre-computed when the artist is created
(typically by the histogram chart builder). This avoids re-binning during
every render pass.
When density is true, the counts vector stores probability density
values (each count divided by n * bin_width) rather than raw counts, so
that the total area under the histogram integrates to 1.0.
Fields§
§data: SeriesThe original (un-binned) data values.
bins: usizeThe requested number of bins (used for display/debugging; the actual
bin count is bin_edges.len() - 1).
bin_edges: Vec<f64>Sorted bin edges of length bins + 1. The i-th bin spans
[bin_edges[i], bin_edges[i+1]).
counts: Vec<f64>The count (or density) for each bin. Length equals bin_edges.len() - 1.
color: ColorFill color of the histogram bars.
label: Option<String>Optional legend label. When Some, the histogram appears in the legend.
alpha: f64Opacity from 0.0 (fully transparent) to 1.0 (fully opaque).
density: boolWhen true, counts stores probability density instead of raw counts.
Implementations§
Source§impl HistArtist
impl HistArtist
Sourcepub fn data_bounds(&self) -> (f64, f64, f64, f64)
pub fn data_bounds(&self) -> (f64, f64, f64, f64)
Computes the data-space bounding box (xmin, xmax, ymin, ymax).
The x-axis spans from the first bin edge to the last bin edge. The
y-axis spans from 0.0 to the tallest bin count (or density value).
Returns (0.0, 1.0, 0.0, 1.0) when there are no bin edges.
Source§impl HistArtist
impl HistArtist
Sourcepub fn label(&mut self, label: &str) -> &mut Self
pub fn label(&mut self, label: &str) -> &mut Self
Sets the legend label for this histogram.
When a label is set, the histogram will appear in the legend if one is displayed on the axes. Pass an empty string or omit this call to exclude the histogram from the legend. Calling this method again overwrites any previously set label.
§Arguments
label- A string slice that will be stored as the legend entry.
§Examples
artist.label("Scores");Sourcepub fn alpha(&mut self, alpha: f64) -> &mut Self
pub fn alpha(&mut self, alpha: f64) -> &mut Self
Sets the opacity (0.0 = fully transparent, 1.0 = fully opaque).
The value is clamped to the [0.0, 1.0] range. The default opacity
is determined by the active theme (typically 0.7 for histograms so
that overlapping distributions remain visible).
§Arguments
alpha- The desired opacity level.
§Examples
artist.alpha(0.5); // 50% transparentSourcepub fn density(&mut self, density: bool) -> &mut Self
pub fn density(&mut self, density: bool) -> &mut Self
Controls whether the histogram displays probability density instead of raw counts.
When density is true, the counts vector is normalized so that
the total area under the histogram integrates to 1.0. Each bin’s
value becomes count / (total * bin_width). This is useful for
comparing distributions with different sample sizes or overlaying a
probability density function.
When density is false (the default), the counts vector stores
raw frequency counts.
§Arguments
density- Iftrue, normalize the histogram to unit area.
§Examples
artist.density(true); // show probability densityTrait Implementations§
Source§impl Clone for HistArtist
impl Clone for HistArtist
Source§fn clone(&self) -> HistArtist
fn clone(&self) -> HistArtist
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more