pub struct EcdfPlot {Show 15 fields
pub groups: Vec<EcdfGroup>,
pub complementary: bool,
pub show_confidence_band: bool,
pub band_alpha: f64,
pub show_rug: bool,
pub rug_height: f64,
pub percentile_lines: Vec<f64>,
pub show_markers: bool,
pub marker_size: f64,
pub smooth: bool,
pub smooth_samples: usize,
pub stroke_width: f64,
pub legend_label: Option<String>,
pub color: String,
pub line_dash: Option<String>,
}Expand description
Builder for an Empirical Cumulative Distribution Function (ECDF) plot.
Supports single or multiple groups, complementary CDF mode (1 - F(x)),
DKW 95% confidence bands, rug plots, percentile reference lines,
per-step markers, and a smooth KDE-integrated CDF.
§Simple example
use kuva::plot::EcdfPlot;
use kuva::backend::svg::SvgBackend;
use kuva::render::render::render_multiple;
use kuva::render::layout::Layout;
use kuva::render::plots::Plot;
let data: Vec<f64> = vec![1.2, 3.4, 2.1, 5.6, 4.0, 0.8, 3.3, 2.7];
let plot = EcdfPlot::new()
.with_data("Sample", data)
.with_color("steelblue")
.with_confidence_band();
let plots = vec![Plot::Ecdf(plot)];
let layout = Layout::auto_from_plots(&plots)
.with_title("ECDF")
.with_x_label("Value")
.with_y_label("F(x)");
let svg = SvgBackend.render_scene(&render_multiple(plots, layout));
std::fs::write("ecdf.svg", svg).unwrap();Fields§
§groups: Vec<EcdfGroup>§complementary: boolPlot 1 - F(x) instead of F(x) (complementary / survival function).
show_confidence_band: boolDraw a DKW 95% confidence band around the step function.
band_alpha: f64Opacity of the confidence band fill (default 0.15).
show_rug: boolDraw a rug of tick marks at each data point below the x-axis.
rug_height: f64Height of rug tick marks in pixels (default 6.0).
percentile_lines: Vec<f64>Horizontal dashed reference lines at these percentile levels (0–1).
show_markers: boolShow a circle marker at each step endpoint.
marker_size: f64Marker radius in pixels (default 3.0).
smooth: boolUse a smooth KDE-integrated CDF instead of the step function.
smooth_samples: usizeNumber of grid points for smooth CDF estimation (default 200).
stroke_width: f64Line stroke width (default 1.5).
legend_label: Option<String>When Some, the legend is rendered using group labels.
color: StringDefault color used for single-group plots and palette auto-assignment.
line_dash: Option<String>Optional SVG stroke-dasharray (e.g. "6,3").
Implementations§
Source§impl EcdfPlot
impl EcdfPlot
Sourcepub fn with_data<S, I, T>(self, label: S, data: I) -> Self
pub fn with_data<S, I, T>(self, label: S, data: I) -> Self
Add a group of data values.
let plot = EcdfPlot::new()
.with_data("Group A", vec![1.0, 2.0, 3.0])
.with_data("Group B", vec![2.0, 4.0, 6.0])
.with_legend("Samples");Sourcepub fn with_data_colored<S, C, I, T>(self, label: S, data: I, color: C) -> Self
pub fn with_data_colored<S, C, I, T>(self, label: S, data: I, color: C) -> Self
Add a group with an explicit color.
Sourcepub fn with_groups<G, S, I, T>(self, groups: G) -> Self
pub fn with_groups<G, S, I, T>(self, groups: G) -> Self
Add multiple groups at once. Each item is a (label, values) pair.
let groups = vec![
("Control", vec![1.0, 2.0, 3.0]),
("Treated", vec![2.0, 4.0, 6.0]),
];
let plot = EcdfPlot::new().with_groups(groups).with_legend("Groups");Sourcepub fn with_complementary(self) -> Self
pub fn with_complementary(self) -> Self
Plot 1 - F(x) instead of F(x).
The complementary CDF (CCDF / survival function) is the standard view for heavy-tailed distributions, sequencing read lengths, and coverage distributions — it emphasises the tail rather than the bulk.
Sourcepub fn with_confidence_band(self) -> Self
pub fn with_confidence_band(self) -> Self
Draw a shaded DKW 95% confidence band around the ECDF.
The band width is ε = √(ln(2/0.05) / (2n)). Useful for small samples
where two curves look different but the overlap in their bands shows
they are not statistically distinguishable.
Sourcepub fn with_band_alpha(self, alpha: f64) -> Self
pub fn with_band_alpha(self, alpha: f64) -> Self
Set the confidence band fill opacity (default 0.15).
Sourcepub fn with_rug(self) -> Self
pub fn with_rug(self) -> Self
Draw a rug of tick marks at each data point just below the x-axis.
Shows the density of raw observations — clusters and gaps that the step function alone can obscure, especially for small samples.
Sourcepub fn with_rug_height(self, px: f64) -> Self
pub fn with_rug_height(self, px: f64) -> Self
Set the height of rug tick marks in pixels (default 6.0).
Sourcepub fn with_percentile_lines(self, percentiles: Vec<f64>) -> Self
pub fn with_percentile_lines(self, percentiles: Vec<f64>) -> Self
Draw horizontal dashed reference lines at the given percentile levels.
Each value should be in [0.0, 1.0]. Labels are placed at the right edge.
let plot = EcdfPlot::new()
.with_data("Sample", vec![1.0, 2.0, 3.0, 4.0, 5.0])
.with_percentile_lines(vec![0.25, 0.5, 0.75]);Sourcepub fn with_markers(self) -> Self
pub fn with_markers(self) -> Self
Show a circle marker at each step transition.
Most useful for small samples (n < 30) where the discrete jumps in the ECDF indicate individual data points.
Sourcepub fn with_marker_size(self, r: f64) -> Self
pub fn with_marker_size(self, r: f64) -> Self
Set the marker radius in pixels (default 3.0).
Sourcepub fn with_smooth(self) -> Self
pub fn with_smooth(self) -> Self
Use a smooth KDE-integrated CDF instead of the empirical step function.
Bandwidth is chosen by Silverman’s rule-of-thumb.
Sourcepub fn with_smooth_samples(self, n: usize) -> Self
pub fn with_smooth_samples(self, n: usize) -> Self
Set the number of grid points for smooth CDF estimation (default 200).
Sourcepub fn with_stroke_width(self, w: f64) -> Self
pub fn with_stroke_width(self, w: f64) -> Self
Set the line stroke width in pixels (default 1.5).
Sourcepub fn with_color<S: Into<String>>(self, color: S) -> Self
pub fn with_color<S: Into<String>>(self, color: S) -> Self
Set a uniform color (used for single-group plots and palette auto-assignment).
Sourcepub fn with_legend<S: Into<String>>(self, title: S) -> Self
pub fn with_legend<S: Into<String>>(self, title: S) -> Self
Show the legend. Pass an empty string "" to show group labels without
a title, or a non-empty string for a titled legend.
Sourcepub fn with_line_dash<S: Into<String>>(self, dash: S) -> Self
pub fn with_line_dash<S: Into<String>>(self, dash: S) -> Self
Set a dashed stroke pattern (SVG stroke-dasharray), e.g. "6,3".
Trait Implementations§
Auto Trait Implementations§
impl Freeze for EcdfPlot
impl RefUnwindSafe for EcdfPlot
impl Send for EcdfPlot
impl Sync for EcdfPlot
impl Unpin for EcdfPlot
impl UnsafeUnpin for EcdfPlot
impl UnwindSafe for EcdfPlot
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
Source§fn to_owned_obj(&self, data: FontData<'_>) -> U
fn to_owned_obj(&self, data: FontData<'_>) -> U
T, using the provided data to resolve any offsets.