pub struct ViolinArtist {
pub datasets: Vec<Vec<f64>>,
pub positions: Option<Vec<f64>>,
pub widths: f64,
pub show_median: bool,
pub show_quartiles: bool,
pub color: Color,
pub alpha: f64,
pub label: Option<String>,
pub bw_method: f64,
}Expand description
A violin plot showing the probability density of data distributions.
Each dataset produces a mirrored kernel density estimate (KDE) shape, similar to a boxplot but showing the full distribution. Optional median and quartile lines can be drawn inside the violin.
Fields§
§datasets: Vec<Vec<f64>>One dataset per violin. Each inner Vec<f64> contains the raw values.
positions: Option<Vec<f64>>Optional x-positions for each violin. Defaults to 1, 2, 3, etc.
widths: f64Maximum width of each violin shape.
show_median: boolWhether to draw a median line inside each violin.
show_quartiles: boolWhether to draw Q1/Q3 quartile lines inside each violin.
color: ColorFill color of the violin shapes.
alpha: f64Opacity from 0.0 (fully transparent) to 1.0 (fully opaque).
label: Option<String>Optional legend label.
bw_method: f64KDE bandwidth override. When <= 0.0, Silverman’s rule is used.
Implementations§
Source§impl ViolinArtist
impl ViolinArtist
Sourcepub fn color(&mut self, color: Color) -> &mut Self
pub fn color(&mut self, color: Color) -> &mut Self
Sets the fill color.
Applies the given Color to every violin rendered by this artist.
Sourcepub fn label(&mut self, label: &str) -> &mut Self
pub fn label(&mut self, label: &str) -> &mut Self
Sets the legend label.
When a legend is displayed on the figure, this label will appear next to the color swatch for this violin plot.
Sourcepub fn alpha(&mut self, alpha: f64) -> &mut Self
pub fn alpha(&mut self, alpha: f64) -> &mut Self
Sets the opacity.
The value is clamped to the range [0.0, 1.0], where 0.0 is fully transparent and 1.0 is fully opaque.
Sourcepub fn widths(&mut self, widths: f64) -> &mut Self
pub fn widths(&mut self, widths: f64) -> &mut Self
Sets the maximum width of each violin shape.
The value is clamped to [0.1, 2.0]. This controls the visual width of the widest part of the violin.
Sourcepub fn positions(&mut self, positions: Vec<f64>) -> &mut Self
pub fn positions(&mut self, positions: Vec<f64>) -> &mut Self
Sets the x-positions for each violin.
When None (the default), violins are placed at 1.0, 2.0, 3.0, etc.
Sourcepub fn show_median(&mut self, show: bool) -> &mut Self
pub fn show_median(&mut self, show: bool) -> &mut Self
Controls whether the median line is drawn.
When true (the default), a horizontal line is drawn at the median
of each dataset inside the violin shape.
Sourcepub fn show_quartiles(&mut self, show: bool) -> &mut Self
pub fn show_quartiles(&mut self, show: bool) -> &mut Self
Controls whether Q1/Q3 quartile lines are drawn.
When true (the default), thin horizontal lines are drawn at the
first and third quartiles inside the violin shape.
Sourcepub fn bw_method(&mut self, bw: f64) -> &mut Self
pub fn bw_method(&mut self, bw: f64) -> &mut Self
Sets the KDE bandwidth manually.
Overrides the automatically computed Silverman’s rule bandwidth. A value of 0.0 or negative resets to automatic bandwidth selection.
Sourcepub fn position_for(&self, index: usize) -> f64
pub fn position_for(&self, index: usize) -> f64
Returns the x-position for a given violin index.
Uses custom positions if set, otherwise defaults to 1-based indexing.
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-bounds span from the leftmost position minus half the max width
to the rightmost position plus half the max width. The y-bounds span
from the minimum data value to the maximum data value across all
datasets. Falls back to (0.0, 1.0, 0.0, 1.0) when there are no
datasets.
Trait Implementations§
Source§impl Clone for ViolinArtist
impl Clone for ViolinArtist
Source§fn clone(&self) -> ViolinArtist
fn clone(&self) -> ViolinArtist
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more