{"spec_id":"errorbar-asymmetric","library":"seaborn","language":"python","code":"\"\"\" anyplot.ai\nerrorbar-asymmetric: Asymmetric Error Bars Plot\nLibrary: seaborn 0.13.2 | Python 3.13.13\nQuality: 96/100 | Updated: 2026-05-13\n\"\"\"\n\nimport os\n\nimport matplotlib.pyplot as plt\nimport numpy as np\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\nBRAND = \"#009E73\"  # Okabe-Ito position 1\n\n# Data: Battery life measurements across device models (10th-90th percentile)\nnp.random.seed(42)\n\ndevices = [\"Model A\", \"Model B\", \"Model C\", \"Model D\", \"Model E\", \"Model F\", \"Model G\", \"Model H\"]\nx = np.arange(len(devices))\n\n# Central values (median battery life in hours)\ny = np.array([8.5, 12.3, 6.2, 15.8, 9.7, 11.2, 7.4, 14.1])\n\n# Asymmetric errors (10th-90th percentile bounds)\n# Lower errors: distance from median to 10th percentile\nerror_lower = np.array([1.2, 2.5, 0.8, 3.2, 1.5, 2.0, 1.0, 2.8])\n# Upper errors: distance from median to 90th percentile\nerror_upper = np.array([2.8, 1.5, 2.2, 1.8, 3.5, 1.2, 2.6, 1.4])\n\n# Create figure with theme-aware background\nfig, ax = plt.subplots(figsize=(16, 9), facecolor=PAGE_BG)\nax.set_facecolor(PAGE_BG)\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    },\n)\n\n# Plot points using seaborn scatterplot\nsns.scatterplot(x=x, y=y, s=400, color=BRAND, zorder=5, ax=ax)\n\n# Add asymmetric error bars using matplotlib errorbar\nax.errorbar(\n    x=x, y=y, yerr=[error_lower, error_upper], fmt=\"none\", ecolor=BRAND, elinewidth=3, capsize=10, capthick=3, zorder=4\n)\n\n# Style with theme-aware colors\nax.set_xticks(x)\nax.set_xticklabels(devices, fontsize=16, color=INK_SOFT)\nax.set_xlabel(\"Device Model\", fontsize=20, color=INK)\nax.set_ylabel(\"Battery Life (hours)\", fontsize=20, color=INK)\nax.set_title(\"errorbar-asymmetric · seaborn · anyplot.ai\", fontsize=24, fontweight=\"medium\", color=INK)\nax.tick_params(axis=\"y\", labelsize=16, colors=INK_SOFT)\nax.grid(True, alpha=0.10, linestyle=\"-\", linewidth=0.8)\n\n# Remove top and right spines\nax.spines[\"top\"].set_visible(False)\nax.spines[\"right\"].set_visible(False)\nax.spines[\"left\"].set_color(INK_SOFT)\nax.spines[\"bottom\"].set_color(INK_SOFT)\n\n# Add theme-aware annotation explaining the error bars\nax.annotate(\n    \"10th–90th percentile\",\n    xy=(0.98, 0.02),\n    xycoords=\"axes fraction\",\n    fontsize=14,\n    ha=\"right\",\n    va=\"bottom\",\n    color=INK,\n    bbox={\"boxstyle\": \"round,pad=0.5\", \"facecolor\": ELEVATED_BG, \"edgecolor\": INK_SOFT, \"linewidth\": 1.5, \"alpha\": 0.9},\n)\n\nplt.tight_layout()\nplt.savefig(f\"plot-{THEME}.png\", dpi=300, bbox_inches=\"tight\", facecolor=PAGE_BG)\n"}