cogra
GitHub

Every geom

One function for each ggplot2 4.0 geom, drawn in black ink. Each takes a matplotlib Axes first; extra keywords go to matplotlib. All data are synthetic.

49 panels, from examples/gallery.py. With toggle worn on (top right) each is shown as save_vintage saves it.
The shared setup code (data used by the panels below)
rng = np.random.default_rng(7)
x = rng.normal(0, 1, 150)
y = 0.6 * x + rng.normal(0, 0.8, 150)
grp = np.where(rng.random(150) < 0.5, "a", "b")
xs = np.linspace(0, 10, 25)
ys = np.sin(xs) + 1.5
X, Y = np.meshgrid(np.linspace(-2, 2, 80), np.linspace(-2, 2, 80))
Z = np.exp(-(X**2 + Y**2)) - 0.6 * np.exp(-((X - 1) ** 2 + (Y + 0.8) ** 2) / 0.4)


def map_regions(nx=5, ny=4, seed=3):
    """Non-overlapping synthetic regions: cells of a jittered grid."""
    r = np.random.default_rng(seed)
    gx, gy = np.meshgrid(np.linspace(0, 1, nx + 1), np.linspace(0, 0.8, ny + 1))
    inner = (gx > 0) & (gx < 1) & (gy > 0) & (gy < 0.8)
    gx = gx + inner * r.uniform(-0.06, 0.06, gx.shape)
    gy = gy + inner * r.uniform(-0.05, 0.05, gy.shape)
    return [
        np.array(
            [
                [gx[j, i], gy[j, i]],
                [gx[j, i + 1], gy[j, i + 1]],
                [gx[j + 1, i + 1], gy[j + 1, i + 1]],
                [gx[j + 1, i], gy[j + 1, i]],
            ]
        )
        for j in range(ny)
        for i in range(nx)
    ]


polys = map_regions()