Minimal call
import random
rng = random.Random(9)
df = {"x": [rng.gauss(0, 1) for _ in range(150)]}
c = pt.chart(df, aes(x="x"), xlabel="value", ylabel="density")
c.add_density_1d(fill=True)
c.add_rug(color="#444444")
Docstring
Rug plot — short tick marks along an axis showing where each observation sits.
No-bin alternative (or companion) to a histogram. Pairs especially well
with `density_1d` to show both the smoothed estimate and the raw
observations.
c.add_rug(aes(x="col")) # columns via aes (orientation="y" too)
c.add_rug(aes(x="col", color="group")) # ticks colored per group
Aesthetics:
color= bare → literal tick color; aes(color="col") → grouped ticks
palette= maps group levels → colors when color is mapped in aes
Other styling kwargs:
orientation='x' 'y' draws ticks along the left axis instead
length=0.04 tick length as a fraction of axis pixel extent
alpha=0.6 tick opacity
linewidth=0.8 tick stroke width
rasterize=None None = auto-raster ticks to one <image> above the point
threshold; True/False forces it on/off