Minimal call
import math
xs = [i * 0.2 for i in range(40)]
df = {"x": xs, "y": [math.sin(x) for x in xs]}
c = pt.chart(df, aes(x="x", y="y"), xlabel="x", ylabel="y")
c.add_line()
Worked example
import plotlet as pt
from plotlet import aes
df = pt.load_dataset("flights")
t = [df["year"][i] + (i % 12) / 12 for i in range(len(df["year"]))]
series = {"t": t, "n": df["passengers"]}
c = pt.chart(series, aes(x="t", y="n"), title="airline passengers",
xlabel="year", ylabel="passengers / month",
data_width=460, data_height=200, gridlines=True)
c.add_line()
Docstring
Line / step — connected xy points, single-series per record.
c.add_line(aes(x="col_x", y="col_y")) # columns via aes
c.add_line(aes(x="col_x", y="col_y", color="g")) # one line per color level
c.add_line(aes(x="col_x", y="col_y", # invisible split — one
color="cohort", group="subject")) # line per subject,
# colors only by cohort
c.add_line(aes(...), linestyle="--") # literal dash
c.add_line(aes(..., linestyle="cohort")) # dash cycle per level
c.add_line(aes(..., alpha="cohort"), alphas=(.3, 1)) # opacity per level
c.add_line(aes(...), arc=False) # straight chords under
# CircularCoordinate
# (no-op in Cartesian)
c.add_step(aes(x="col_x", y="col_y"), where="post") # step variant; where=
# "pre" | "post" | "mid"
c.add_line(aes(x="dose", y="resp"), # aggregate replicate
estimator="mean") # rows per x with a
# CI band (seaborn
# lineplot)
Aggregation (estimator=): replicate rows sharing an x collapse to their
mean/median, drawn with a shaded CI band. `ci="t"` (default) is the
analytic t interval on the mean; `ci="boot"` a percentile bootstrap
(any estimator); `ci=None` just the aggregated line. `level=0.95`,
`n_boot=1000`, `seed=0`, `band_alpha=0.2` tune it. Applies per series
after color=/group= splitting; needs curve='linear'.
`linestyle="--"` (bare) is always a literal dash (`"--"`, `":"`,
`"6,3,1,3"`). `aes(linestyle="col")` maps the column: dash patterns
cycle per level.
Dense lines (simplify=): a long series is one `<path>`, so the cost is
the d-string size, not the node count. Above `dense_threshold`
vertices (or with `simplify=True`; `False` never) the affine path drops
the vertices the stroke can't show at pixel resolution — same drawn
pixels, far smaller output (see `draw/_simplify.py`). Auto mode skips
dashed lines, whose dash phase follows arc length.
Column-driven splitting (any of `color`/`group`/`linestyle`/`alpha` in aes) is
handled at the Chart layer — the artist itself always sees one series
per record.