{"spec_id":"bar-error","library":"matplotlib","language":"python","code":"\"\"\" anyplot.ai\nbar-error: Bar Chart with Error Bars\nLibrary: matplotlib 3.10.9 | Python 3.13.13\nQuality: 86/100 | Updated: 2026-05-10\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\"\nBRAND = \"#009E73\"  # Okabe-Ito position 1\n\n# Data: A/B test results comparing feature variants with confidence intervals\nnp.random.seed(42)\ncategories = [\"Control\", \"Variant A\", \"Variant B\", \"Variant C\", \"Variant D\"]\nvalues = [12.3, 15.8, 14.2, 18.5, 11.7]\nerrors = [1.2, 2.1, 1.5, 2.8, 1.0]\n\n# Plot\nfig, ax = plt.subplots(figsize=(16, 9), facecolor=PAGE_BG)\nax.set_facecolor(PAGE_BG)\n\nx = np.arange(len(categories))\nbar_width = 0.6\n\nbars = ax.bar(x, values, bar_width, color=BRAND, edgecolor=INK_SOFT, linewidth=1.5)\nax.errorbar(x, values, yerr=errors, fmt=\"none\", ecolor=INK_SOFT, elinewidth=2.5, capsize=8, capthick=2)\n\n# Labels and styling\nax.set_xlabel(\"Test Group\", fontsize=20, color=INK)\nax.set_ylabel(\"Conversion Rate (%)\", fontsize=20, color=INK)\nax.set_title(\"bar-error · matplotlib · anyplot.ai\", fontsize=24, fontweight=\"medium\", color=INK)\nax.set_xticks(x)\nax.set_xticklabels(categories, fontsize=16, color=INK_SOFT)\nax.tick_params(axis=\"y\", labelsize=16, colors=INK_SOFT)\n\n# Spines\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)\n\n# Grid\nax.yaxis.grid(True, alpha=0.15, linewidth=0.8, color=INK)\n\n# Annotation\nax.annotate(\n    \"Error bars: 95% CI\",\n    xy=(0.98, 0.02),\n    xycoords=\"axes fraction\",\n    fontsize=14,\n    ha=\"right\",\n    va=\"bottom\",\n    color=INK_SOFT,\n    bbox={\n        \"boxstyle\": \"round,pad=0.5\",\n        \"facecolor\": ELEVATED_BG,\n        \"edgecolor\": INK_SOFT,\n        \"alpha\": 0.9,\n        \"linewidth\": 1,\n    },\n)\n\nax.set_ylim(0, max(values) * 1.3)\n\nplt.tight_layout()\nplt.savefig(f\"plot-{THEME}.png\", dpi=300, bbox_inches=\"tight\", facecolor=PAGE_BG)\n"}