{"spec_id":"errorbar-asymmetric","library":"matplotlib","language":"python","code":"\"\"\" anyplot.ai\nerrorbar-asymmetric: Asymmetric Error Bars Plot\nLibrary: matplotlib 3.10.9 | Python 3.13.13\nQuality: 93/100 | Updated: 2026-05-13\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: Monthly sales performance with asymmetric confidence intervals\nnp.random.seed(42)\nmonths = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\"]\nsales = np.array([42, 55, 48, 61, 73, 68, 82, 78])\n\n# Asymmetric errors: lower bound smaller (more confident), upper larger (more uncertain)\nerror_lower = np.array([5, 8, 6, 9, 7, 10, 8, 6])\nerror_upper = np.array([12, 15, 10, 18, 14, 20, 16, 12])\n\n# Plot\nfig, ax = plt.subplots(figsize=(16, 9), facecolor=PAGE_BG)\nax.set_facecolor(PAGE_BG)\n\n# Error bars with asymmetric magnitudes\nax.errorbar(\n    months,\n    sales,\n    yerr=[error_lower, error_upper],\n    fmt=\"o\",\n    markersize=22,\n    color=BRAND,\n    ecolor=BRAND,\n    elinewidth=3,\n    capsize=10,\n    capthick=3,\n    alpha=0.9,\n    label=\"Median with 10th-90th percentile bounds\",\n)\n\n# Subtle fill to show confidence region\nx_positions = np.arange(len(months))\nax.fill_between(x_positions, sales - error_lower, sales + error_upper, alpha=0.15, color=BRAND)\n\n# Style\nax.set_xlabel(\"Month\", fontsize=20, color=INK)\nax.set_ylabel(\"Sales (thousands USD)\", fontsize=20, color=INK)\nax.set_title(\"errorbar-asymmetric · matplotlib · anyplot.ai\", fontsize=24, color=INK)\nax.tick_params(axis=\"both\", labelsize=16, colors=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_SOFT)\n\n# Legend\nleg = ax.legend(fontsize=16, loc=\"upper left\", framealpha=0.95)\nif leg:\n    leg.get_frame().set_facecolor(ELEVATED_BG)\n    leg.get_frame().set_edgecolor(INK_SOFT)\n    for text in leg.get_texts():\n        text.set_color(INK_SOFT)\n\nax.set_ylim(0, 120)\nplt.tight_layout()\nplt.savefig(f\"plot-{THEME}.png\", dpi=300, bbox_inches=\"tight\", facecolor=PAGE_BG)\n"}