{"spec_id":"strip-basic","library":"plotnine","language":"python","code":"\"\"\" anyplot.ai\nstrip-basic: Basic Strip Plot\nLibrary: plotnine 0.15.7 | Python 3.13.14\nQuality: 90/100 | Updated: 2026-08-05\n\"\"\"\n\nimport os\n\nimport numpy as np\nimport pandas as pd\nfrom plotnine import (\n    aes,\n    annotate,\n    element_line,\n    element_rect,\n    element_text,\n    geom_point,\n    ggplot,\n    labs,\n    position_jitter,\n    scale_fill_manual,\n    stat_summary,\n    theme,\n    theme_minimal,\n)\n\n\n# Theme tokens\nTHEME = os.getenv(\"ANYPLOT_THEME\", \"light\")\nPAGE_BG = \"#FAF8F1\" if THEME == \"light\" else \"#1A1A17\"\nELEVATED_BG = \"#FFFDF6\" if THEME == \"light\" else \"#242420\"\nINK = \"#1A1A17\" if THEME == \"light\" else \"#F0EFE8\"\nINK_SOFT = \"#4A4A44\" if THEME == \"light\" else \"#B8B7B0\"\n\nIMPRINT = [\"#009E73\", \"#C475FD\", \"#4467A3\", \"#BD8233\"]\nNEUTRAL = INK  # Imprint semantic anchor for reference lines / baselines\n\n# Data - Patient response times (seconds) across different drug treatments\nnp.random.seed(42)\n\ndistributions = {\n    \"Placebo\": {\"mean\": 45, \"std\": 12, \"n\": 40},\n    \"Drug A\": {\"mean\": 32, \"std\": 8, \"n\": 45},\n    \"Drug B\": {\"mean\": 28, \"std\": 10, \"n\": 42},\n    \"Drug C\": {\"mean\": 25, \"std\": 6, \"n\": 38},\n}\n\ndata = []\nfor treatment, params in distributions.items():\n    times = np.random.normal(params[\"mean\"], params[\"std\"], params[\"n\"])\n    times = np.clip(times, 5, 80)\n    data.extend([(treatment, time) for time in times])\n\ndf = pd.DataFrame(data, columns=[\"treatment\", \"response_time\"])\ndf[\"treatment\"] = pd.Categorical(df[\"treatment\"], categories=list(distributions), ordered=True)\n\n# Plot\nplot = (\n    ggplot(df, aes(x=\"treatment\", y=\"response_time\"))\n    + geom_point(\n        aes(fill=\"treatment\"),\n        position=position_jitter(width=0.25, height=0, random_state=42),\n        color=PAGE_BG,\n        stroke=0.3,\n        size=2.5,\n        alpha=0.65,\n    )\n    + stat_summary(\n        fun_y=np.mean, fun_ymin=np.mean, fun_ymax=np.mean, geom=\"crossbar\", width=0.4, color=NEUTRAL, size=0.4\n    )\n    + annotate(\"text\", x=\"Drug C\", y=8, label=\"Fastest response\", color=INK, size=8, fontweight=\"bold\", ha=\"center\")\n    + scale_fill_manual(values=IMPRINT)\n    + labs(x=\"Treatment Group\", y=\"Response Time (seconds)\", title=\"strip-basic · plotnine · anyplot.ai\")\n    + theme_minimal()\n    + theme(\n        figure_size=(8, 4.5),\n        plot_background=element_rect(fill=PAGE_BG, color=PAGE_BG),\n        panel_background=element_rect(fill=PAGE_BG),\n        panel_grid_major=element_line(color=INK, size=0.3, alpha=0.20),\n        panel_grid_minor=element_line(color=INK, size=0.15, alpha=0.08),\n        axis_line=element_line(color=INK_SOFT, size=0.5),\n        axis_title=element_text(color=INK, size=10),\n        axis_text=element_text(color=INK_SOFT, size=8),\n        plot_title=element_text(color=INK, size=18, weight=\"bold\"),\n        legend_position=\"none\",\n    )\n)\n\n# Save\nplot.save(f\"plot-{THEME}.png\", dpi=400, width=8, height=4.5, units=\"in\", verbose=False)\n"}