{"spec_id":"cat-box-strip","library":"seaborn","language":"python","code":"\"\"\" anyplot.ai\ncat-box-strip: Box Plot with Strip Overlay\nLibrary: seaborn 0.13.2 | Python 3.13.13\nQuality: 92/100 | Updated: 2026-05-13\n\"\"\"\n\nimport os\n\nimport matplotlib.pyplot as plt\nimport numpy as np\nimport pandas as pd\nimport seaborn as sns\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\n# Okabe-Ito palette - brand green for boxes, vermillion for strip points\nBRAND = \"#009E73\"\nACCENT = \"#C475FD\"\n\n# Data - product quality scores across manufacturing batches\nnp.random.seed(42)\n\n# Create groups with different distributions to show boxplot features\nbatch_a = np.random.normal(75, 8, 40)  # Centered, moderate spread\nbatch_b = np.random.normal(82, 5, 35)  # Higher center, tight spread\nbatch_c = np.concatenate(\n    [\n        np.random.normal(68, 6, 30),  # Main distribution\n        [45, 48, 95, 97],  # Outliers\n    ]\n)\nbatch_d = np.random.normal(70, 12, 45)  # Wide spread\n\n# Combine into DataFrame\ndf = pd.DataFrame(\n    {\n        \"Batch\": [\"Batch A\"] * len(batch_a)\n        + [\"Batch B\"] * len(batch_b)\n        + [\"Batch C\"] * len(batch_c)\n        + [\"Batch D\"] * len(batch_d),\n        \"Quality Score\": np.concatenate([batch_a, batch_b, batch_c, batch_d]),\n    }\n)\n\n# Configure seaborn theme\nsns.set_theme(\n    style=\"ticks\",\n    rc={\n        \"figure.facecolor\": PAGE_BG,\n        \"axes.facecolor\": PAGE_BG,\n        \"axes.edgecolor\": INK_SOFT,\n        \"axes.labelcolor\": INK,\n        \"text.color\": INK,\n        \"xtick.color\": INK_SOFT,\n        \"ytick.color\": INK_SOFT,\n        \"grid.color\": INK,\n        \"grid.alpha\": 0.10,\n        \"legend.facecolor\": ELEVATED_BG,\n        \"legend.edgecolor\": INK_SOFT,\n    },\n)\n\n# Plot\nfig, ax = plt.subplots(figsize=(16, 9), facecolor=PAGE_BG)\nax.set_facecolor(PAGE_BG)\n\n# Box plot in brand green\nsns.boxplot(data=df, x=\"Batch\", y=\"Quality Score\", color=BRAND, width=0.5, linewidth=2, fliersize=0, ax=ax)\n\n# Strip plot overlay in accent vermillion\nsns.stripplot(\n    data=df,\n    x=\"Batch\",\n    y=\"Quality Score\",\n    color=ACCENT,\n    size=10,\n    alpha=0.7,\n    jitter=0.2,\n    edgecolor=PAGE_BG,\n    linewidth=0.5,\n    ax=ax,\n)\n\n# Style\nax.set_title(\"cat-box-strip · seaborn · anyplot.ai\", fontsize=24, color=INK)\nax.set_xlabel(\"Manufacturing Batch\", fontsize=20, color=INK)\nax.set_ylabel(\"Quality Score (points)\", fontsize=20, color=INK)\nax.tick_params(axis=\"both\", labelsize=16, colors=INK_SOFT)\n\n# Spines\nax.spines[\"top\"].set_visible(False)\nax.spines[\"right\"].set_visible(False)\nfor spine in (\"left\", \"bottom\"):\n    ax.spines[spine].set_color(INK_SOFT)\n\n# Grid\nax.yaxis.grid(True, alpha=0.10, linewidth=0.8, color=INK)\n\n# Y-axis limits with padding\nax.set_ylim(35, 105)\n\nplt.tight_layout()\nplt.savefig(f\"plot-{THEME}.png\", dpi=300, bbox_inches=\"tight\", facecolor=PAGE_BG)\n"}