Skip to main content

EcdfPlot

Struct EcdfPlot 

Source
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: bool

Plot 1 - F(x) instead of F(x) (complementary / survival function).

§show_confidence_band: bool

Draw a DKW 95% confidence band around the step function.

§band_alpha: f64

Opacity of the confidence band fill (default 0.15).

§show_rug: bool

Draw a rug of tick marks at each data point below the x-axis.

§rug_height: f64

Height 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: bool

Show a circle marker at each step endpoint.

§marker_size: f64

Marker radius in pixels (default 3.0).

§smooth: bool

Use a smooth KDE-integrated CDF instead of the step function.

§smooth_samples: usize

Number of grid points for smooth CDF estimation (default 200).

§stroke_width: f64

Line stroke width (default 1.5).

§legend_label: Option<String>

When Some, the legend is rendered using group labels.

§color: String

Default 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

Source

pub fn new() -> Self

Create an ECDF plot with default settings.

Source

pub fn with_data<S, I, T>(self, label: S, data: I) -> Self
where S: Into<String>, I: IntoIterator<Item = T>, T: Into<f64>,

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");
Source

pub fn with_data_colored<S, C, I, T>(self, label: S, data: I, color: C) -> Self
where S: Into<String>, C: Into<String>, I: IntoIterator<Item = T>, T: Into<f64>,

Add a group with an explicit color.

Source

pub fn with_groups<G, S, I, T>(self, groups: G) -> Self
where G: IntoIterator<Item = (S, I)>, S: Into<String>, I: IntoIterator<Item = T>, T: Into<f64>,

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");
Source

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.

Source

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.

Source

pub fn with_band_alpha(self, alpha: f64) -> Self

Set the confidence band fill opacity (default 0.15).

Source

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.

Source

pub fn with_rug_height(self, px: f64) -> Self

Set the height of rug tick marks in pixels (default 6.0).

Source

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]);
Source

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.

Source

pub fn with_marker_size(self, r: f64) -> Self

Set the marker radius in pixels (default 3.0).

Source

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.

Source

pub fn with_smooth_samples(self, n: usize) -> Self

Set the number of grid points for smooth CDF estimation (default 200).

Source

pub fn with_stroke_width(self, w: f64) -> Self

Set the line stroke width in pixels (default 1.5).

Source

pub fn with_color<S: Into<String>>(self, color: S) -> Self

Set a uniform color (used for single-group plots and palette auto-assignment).

Source

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.

Source

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§

Source§

impl Clone for EcdfPlot

Source§

fn clone(&self) -> EcdfPlot

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EcdfPlot

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for EcdfPlot

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<EcdfPlot> for Plot

Source§

fn from(p: EcdfPlot) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Finish for T

Source§

fn finish(self)

Does nothing but move self, equivalent to drop.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<U, T> ToOwnedObj<U> for T
where U: FromObjRef<T>,

Source§

fn to_owned_obj(&self, data: FontData<'_>) -> U

Convert this type into T, using the provided data to resolve any offsets.
Source§

impl<U, T> ToOwnedTable<U> for T
where U: FromTableRef<T>,

Source§

fn to_owned_table(&self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.