Marginal rugs on a scatter

side="left" rugs the y axis, so a scatter can carry both marginal distributions without the extra axes a jointplot would need.

plot 05 marginal rug

Live figure — pick a tool, then zoom, pan, point-pick or annotate. Nothing is active until a tool is selected.

View this figure’s Vega export ↗ — the raw JSON spec, rendered live by a real Vega engine.

View this figure’s Vega-Lite export ↗ — the raw JSON spec(s), rendered live by a real Vega-Lite engine.

import numpy as np
import plotpress

rng = np.random.default_rng(11)
n = 250
x = rng.normal(5.9, 0.7, n)
y = 0.55 * x + rng.normal(0.0, 0.35, n)

fig, ax = plotpress.subplots()
ax.scatter(x, y, s=14, color="#1f77b4", alpha=0.55)
ax.rugplot(x, color="#1f77b4", alpha=0.6)
ax.rugplot(y, side="left", color="#1f77b4", alpha=0.6)
ax.set_xlabel("sepal length (cm)")
ax.set_ylabel("petal length (cm)")
ax.set_title("scatter with marginal rugs")
fig.tight_layout()

Total running time of the script: (0 minutes 0.068 seconds)

Gallery generated by Sphinx-Gallery