Minimal call
import random
rng = random.Random(8)
df1 = {"x": [rng.gauss(0, 1) for _ in range(200)]}
df2 = {"x": [rng.gauss(0.6, 1.3) for _ in range(200)]}
c = pt.chart(xlabel="value", ylabel="F(x)")
c.add_ecdf(df1, aes(x="x"))
c.add_ecdf(df2, aes(x="x"))
Worked example
import plotlet as pt
from plotlet import aes
df = pt.load_dataset("tips")
c = pt.chart(df, aes(x="total_bill", color="time"),
title="bill size by service", xlabel="total bill ($)",
ylabel="fraction of parties",
data_width=320, data_height=210)
c.add_ecdf()
Docstring
Empirical CDF as a step function — no bin choice, every observation visible.
F̂(x) = (#{xi ≤ x}) / n as a step function. ECDFs are the statistician-
preferred alternative to histograms: no bin choice, no smoothing, every
observation visible — overlaying multiple groups makes distribution
differences obvious.
c.add_ecdf(aes(x="col")) # columns via aes
c.add_ecdf(aes(x="col", color="group")) # one curve per group
Aesthetics:
color= bare → literal line color; aes(color="col") → grouped curves
palette= maps group levels → colors when color is mapped in aes
Other styling kwargs:
complement=False True draws 1 - F̂(x) (survival function)
linewidth=1.5 stroke width
label=None legend label (single-series only)
simplify=None None = auto-drop step vertices the stroke can't show
above `dense_threshold` observations (the curve has
~2 vertices per observation); True/False forces it
on/off (see draw/_simplify.py)