{"spec_id":"box-notched","library":"matplotlib","language":"python","code":"\"\"\" anyplot.ai\nbox-notched: Notched Box Plot\nLibrary: matplotlib 3.11.1 | Python 3.13.15\nQuality: 90/100 | Updated: 2026-08-18\n\"\"\"\n\nimport os\n\nimport matplotlib.pyplot as plt\nimport numpy as np\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# Imprint palette - first series is always brand green\nIMPRINT = [\"#009E73\", \"#C475FD\", \"#4467A3\", \"#BD8233\", \"#AE3030\"]\n\n# Data - Test success rates across different test suites\nnp.random.seed(42)\n\n# Unit Tests: High success rate, tight distribution\nunit_tests = np.random.normal(loc=97, scale=2, size=65)\nunit_tests = np.clip(unit_tests, 90, 100)\n\n# Integration Tests: Medium-high success rate, wider spread\nintegration_tests = np.random.normal(loc=87, scale=8, size=60)\nintegration_tests = np.clip(integration_tests, 70, 100)\n\n# System Tests: Medium success rate, similar to integration (overlapping notches expected)\nsystem_tests = np.random.normal(loc=85, scale=9, size=55)\nsystem_tests = np.clip(system_tests, 65, 100)\n\n# E2E Tests: Lower success rate with some outliers\ne2e_base = np.random.normal(loc=78, scale=10, size=50)\ne2e_outliers = np.array([98, 99, 45, 42])\ne2e_tests = np.concatenate([e2e_base, e2e_outliers])\ne2e_tests = np.clip(e2e_tests, 30, 100)\n\n# Load Tests: Variable success rate due to infrastructure variance\nload_tests = np.random.normal(loc=75, scale=12, size=45)\nload_tests = np.clip(load_tests, 40, 100)\n\ndata = [unit_tests, integration_tests, system_tests, e2e_tests, load_tests]\ntest_suites = [\"Unit Tests\", \"Integration Tests\", \"System Tests\", \"E2E Tests\", \"Load Tests\"]\n\n# Create plot\nfig, ax = plt.subplots(figsize=(8, 4.5), dpi=400, facecolor=PAGE_BG)\nax.set_facecolor(PAGE_BG)\n\n# Create notched boxplot; showmeans overlays a mean marker so viewers can\n# compare central tendency against the median line (useful for the\n# right-skewed E2E/Load suites, where outliers pull the mean off the median)\nbp = ax.boxplot(\n    data,\n    notch=True,\n    patch_artist=True,\n    tick_labels=test_suites,\n    widths=0.6,\n    showfliers=True,\n    showmeans=True,\n    flierprops={\"marker\": \"o\", \"markerfacecolor\": INK_SOFT, \"markersize\": 7, \"alpha\": 0.6},\n    medianprops={\"color\": INK, \"linewidth\": 2.5},\n    meanprops={\n        \"marker\": \"D\",\n        \"markerfacecolor\": PAGE_BG,\n        \"markeredgecolor\": INK,\n        \"markeredgewidth\": 1.5,\n        \"markersize\": 7,\n    },\n    whiskerprops={\"color\": INK_SOFT, \"linewidth\": 1.5},\n    capprops={\"color\": INK_SOFT, \"linewidth\": 1.5},\n    boxprops={\"color\": INK_SOFT, \"linewidth\": 1.25},\n)\n\n# Apply colors to boxes\nfor patch, color in zip(bp[\"boxes\"], IMPRINT, strict=True):\n    patch.set_facecolor(color)\n    patch.set_alpha(0.75)\n    patch.set_edgecolor(INK_SOFT)\n    patch.set_linewidth(1.25)\n\n# Labels and styling\nax.set_xlabel(\"Test Suite\", fontsize=10, color=INK)\nax.set_ylabel(\"Success Rate (%)\", fontsize=10, color=INK)\nax.set_title(\"box-notched · python · matplotlib · anyplot.ai\", fontsize=12, fontweight=\"medium\", color=INK)\nax.tick_params(axis=\"both\", labelsize=8, colors=INK_SOFT, labelcolor=INK_SOFT)\nax.spines[\"top\"].set_visible(False)\nax.spines[\"right\"].set_visible(False)\nfor s in (\"left\", \"bottom\"):\n    ax.spines[s].set_color(INK_SOFT)\nax.yaxis.grid(True, alpha=0.15, linewidth=0.8, color=INK)\n\n# Add annotation explaining notches; xytext uses axes-fraction coords so the\n# callout stays clear of the title above the axes regardless of data range\nax.annotate(\n    \"Non-overlapping notches suggest\\nsignificant median difference\",\n    xy=(1, 97),\n    xycoords=\"data\",\n    xytext=(0.2, 0.9),\n    textcoords=\"axes fraction\",\n    fontsize=8,\n    color=INK,\n    arrowprops={\"arrowstyle\": \"->\", \"color\": INK_SOFT, \"lw\": 1.2},\n    bbox={\"boxstyle\": \"round,pad=0.5\", \"facecolor\": ELEVATED_BG, \"edgecolor\": INK_SOFT, \"alpha\": 0.9},\n)\n\nplt.tight_layout()\nplt.savefig(f\"plot-{THEME}.png\", dpi=400, facecolor=PAGE_BG)  # bbox_inches MUST stay default (None)\n"}