Basic Strip Plot — plotnine

A strip plot displays individual data points for each category along a single axis, with random horizontal jitter applied to reduce overplotting. Unlike box plots or violin plots that show summary statistics, strip plots reveal every observation, making them ideal for small to medium datasets where individual values matter. The random jitter spreads points horizontally within each category to show density through point accumulation.

Basic Strip Plot rendered with plotnine

Renders

Python source (plotnine)

""" anyplot.ai
strip-basic: Basic Strip Plot
Library: plotnine 0.15.7 | Python 3.13.14
Quality: 90/100 | Updated: 2026-08-05
"""

import os

import numpy as np
import pandas as pd
from plotnine import (
    aes,
    annotate,
    element_line,
    element_rect,
    element_text,
    geom_point,
    ggplot,
    labs,
    position_jitter,
    scale_fill_manual,
    stat_summary,
    theme,
    theme_minimal,
)


# Theme tokens
THEME = os.getenv("ANYPLOT_THEME", "light")
PAGE_BG = "#FAF8F1" if THEME == "light" else "#1A1A17"
ELEVATED_BG = "#FFFDF6" if THEME == "light" else "#242420"
INK = "#1A1A17" if THEME == "light" else "#F0EFE8"
INK_SOFT = "#4A4A44" if THEME == "light" else "#B8B7B0"

IMPRINT = ["#009E73", "#C475FD", "#4467A3", "#BD8233"]
NEUTRAL = INK  # Imprint semantic anchor for reference lines / baselines

# Data - Patient response times (seconds) across different drug treatments
np.random.seed(42)

distributions = {
    "Placebo": {"mean": 45, "std": 12, "n": 40},
    "Drug A": {"mean": 32, "std": 8, "n": 45},
    "Drug B": {"mean": 28, "std": 10, "n": 42},
    "Drug C": {"mean": 25, "std": 6, "n": 38},
}

data = []
for treatment, params in distributions.items():
    times = np.random.normal(params["mean"], params["std"], params["n"])
    times = np.clip(times, 5, 80)
    data.extend([(treatment, time) for time in times])

df = pd.DataFrame(data, columns=["treatment", "response_time"])
df["treatment"] = pd.Categorical(df["treatment"], categories=list(distributions), ordered=True)

# Plot
plot = (
    ggplot(df, aes(x="treatment", y="response_time"))
    + geom_point(
        aes(fill="treatment"),
        position=position_jitter(width=0.25, height=0, random_state=42),
        color=PAGE_BG,
        stroke=0.3,
        size=2.5,
        alpha=0.65,
    )
    + stat_summary(
        fun_y=np.mean, fun_ymin=np.mean, fun_ymax=np.mean, geom="crossbar", width=0.4, color=NEUTRAL, size=0.4
    )
    + annotate("text", x="Drug C", y=8, label="Fastest response", color=INK, size=8, fontweight="bold", ha="center")
    + scale_fill_manual(values=IMPRINT)
    + labs(x="Treatment Group", y="Response Time (seconds)", title="strip-basic · plotnine · anyplot.ai")
    + theme_minimal()
    + theme(
        figure_size=(8, 4.5),
        plot_background=element_rect(fill=PAGE_BG, color=PAGE_BG),
        panel_background=element_rect(fill=PAGE_BG),
        panel_grid_major=element_line(color=INK, size=0.3, alpha=0.20),
        panel_grid_minor=element_line(color=INK, size=0.15, alpha=0.08),
        axis_line=element_line(color=INK_SOFT, size=0.5),
        axis_title=element_text(color=INK, size=10),
        axis_text=element_text(color=INK_SOFT, size=8),
        plot_title=element_text(color=INK, size=18, weight="bold"),
        legend_position="none",
    )
)

# Save
plot.save(f"plot-{THEME}.png", dpi=400, width=8, height=4.5, units="in", verbose=False)

Retrieve this implementation

Runnable source as JSON, for any HTTP client: https://api.anyplot.ai/specs/strip-basic/plotnine/code. Any spec id and library id listed in llms-full.txt fit the same URL shape; every URL below is complete and callable.

{
  "spec_id": "strip-basic",
  "language": "python",
  "library": "plotnine",
  "page": "https://anyplot.ai/strip-basic/python/plotnine",
  "hub": "https://anyplot.ai/strip-basic",
  "code_json": "https://api.anyplot.ai/specs/strip-basic/plotnine/code",
  "spec_json": "https://api.anyplot.ai/specs/strip-basic",
  "render_light_png": "https://storage.googleapis.com/anyplot-images/plots/strip-basic/python/plotnine/plot-light.png",
  "render_dark_png": "https://storage.googleapis.com/anyplot-images/plots/strip-basic/python/plotnine/plot-dark.png",
  "quality_score": 90.0,
  "license": "MIT",
  "guide": "https://anyplot.ai/llms.txt"
}

Part of Basic Strip Plot on anyplot.ai.

Other implementations