ECDFplot: Compare Empirical Cumulative Distributions in One Plot

View source: R/ECDFplot.R

ECDFplotR Documentation

Compare Empirical Cumulative Distributions in One Plot

Description

Draws empirical cumulative distribution functions for user-supplied samples as step curves in a single plot. The samples may have different lengths.

Usage

ECDFplot(Curves, Names = NULL, xlab = "Value",
         ylab = "Cumulative probability",
         main = "Empirical cumulative distributions",
         col = c("#555555", "#2166ac", "#16845b", "#c36720"),
         lty = seq_len(6L), lwd = 2, LegendPosition = "bottomright",
         xlim = NULL, ReferenceLines = c(0.5, 0.8, 0.9),
         PlotIt = TRUE, ...)

Arguments

Curves

A numeric vector, a list of numeric vectors, or a numeric matrix or data frame with one curve per column. List entries may differ in length. Every curve must contain at least one finite observation.

Names

Optional legend labels, one per curve. Defaults to list or column names; unnamed entries receive labels such as "Curve 1".

xlab, ylab, main

Horizontal axis label, vertical axis label and title. All three have general-purpose defaults and can be overridden.

col, lty, lwd

Curve colors, line types and line widths. Vectors are recycled to the number of curves.

LegendPosition

Position accepted by legend, or NULL to omit the legend.

xlim

Optional finite, increasing horizontal axis limits. By default, the pooled range is extended by a small margin. Constant samples are supported.

ReferenceLines

Probabilities for horizontal guide lines, between zero and one. Use NULL to omit them.

PlotIt

If TRUE, draw the plot. If FALSE, only compute and return the curve coordinates.

...

Additional arguments to plot.default, such as cex.main, las or xaxs. The arguments type and ylim are fixed by this function.

Details

For a sample of size n, the curve at x is the fraction of observations less than or equal to x. Ties form a single jump. Curves are right-continuous and are neither smoothed nor linearly interpolated. Each curve uses its own sample size as its denominator.

Missing and infinite observations are omitted with a warning and counted in Removed. The resulting ECDF is conditional on finite observations. In benchmark applications, failed runs should therefore be reported separately; encoding them as missing values does not penalize their curve.

For losses where smaller values are preferable, curves further to the left indicate smaller losses. Crossing curves can favor different methods at different quantiles; the plot alone does not establish an overall winner. Existing multi-panel layouts and graphical settings are not changed.

Value

Invisibly returns a list containing:

Curves

Named list of data frames with columns X (unique sorted observations) and Y (the ECDF at those observations).

N

Named vector of the number of finite observations per curve.

Removed

Named vector of the number of omitted observations per curve.

xlim

The horizontal axis limits used for plotting.

See Also

ecdf, CCDFplot

Examples

Curves = list(Original = c(0.9, 0.3, 0.5, 0.5, 1.2),
              Alternative = c(0.2, 0.4, 0.4, 0.6))
ECDFplot(Curves)
ECDFplot(Curves, xlab = "Search loss (smaller is better)",
         ylab = "Fraction of runs with loss <= x",
         main = "Comparison of search methods")

Result = ECDFplot(Curves, PlotIt = FALSE)
Coordinates = Result$Curves
SampleSizes = Result$N
Coordinates
SampleSizes

DataVisualizations documentation built on Nov. 28, 2026, 5:09 p.m.