{"spec_id":"box-horizontal","library":"matplotlib","language":"python","code":"\"\"\" anyplot.ai\nbox-horizontal: Horizontal Box Plot\nLibrary: matplotlib 3.10.9 | Python 3.13.13\nQuality: 88/100 | Updated: 2026-05-12\n\"\"\"\n\nimport os\nimport sys\nsys.path = [p for p in sys.path if p not in (\"\", \".\")]\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\"\nINK = \"#1A1A17\" if THEME == \"light\" else \"#F0EFE8\"\nINK_SOFT = \"#4A4A44\" if THEME == \"light\" else \"#B8B7B0\"\nBRAND = \"#009E73\"\n\n# Data - Response times (ms) by service type\nnp.random.seed(42)\n\nservices = [\n    \"Authentication Service\",\n    \"Database Query\",\n    \"File Upload\",\n    \"Payment Processing\",\n    \"Email Notification\",\n    \"Image Processing\",\n]\n\n# Generate data with different distributions to show variety\ndata = [\n    np.random.normal(150, 30, 80),  # Auth - tight distribution\n    np.concatenate([np.random.normal(200, 40, 70), [450, 480, 520]]),  # DB - with outliers\n    np.random.normal(500, 100, 90),  # File upload - wider spread\n    np.random.exponential(180, 85) + 100,  # Payment - skewed right\n    np.random.normal(80, 15, 75),  # Email - fast and tight\n    np.random.uniform(300, 800, 60),  # Image - wide uniform spread\n]\n\n# Create figure\nfig, ax = plt.subplots(figsize=(16, 9), facecolor=PAGE_BG)\nax.set_facecolor(PAGE_BG)\n\n# Create horizontal box plot\nbp = ax.boxplot(\n    data,\n    vert=False,\n    tick_labels=services,\n    patch_artist=True,\n    widths=0.6,\n    flierprops={\"marker\": \"o\", \"markersize\": 8, \"markerfacecolor\": BRAND, \"markeredgecolor\": BRAND},\n    medianprops={\"color\": INK, \"linewidth\": 2.5},\n    whiskerprops={\"color\": INK_SOFT, \"linewidth\": 2},\n    capprops={\"color\": INK_SOFT, \"linewidth\": 2},\n    boxprops={\"facecolor\": BRAND, \"edgecolor\": BRAND, \"linewidth\": 2, \"alpha\": 0.7},\n)\n\n# Labels and styling\nax.set_xlabel(\"Response Time (ms)\", fontsize=20, color=INK)\nax.set_ylabel(\"Service Type\", fontsize=20, color=INK)\nax.set_title(\"box-horizontal · matplotlib · anyplot.ai\", fontsize=24, fontweight=\"medium\", 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.xaxis.grid(True, alpha=0.15, linewidth=0.8, color=INK_SOFT)\n\nplt.tight_layout()\nplt.savefig(f\"plot-{THEME}.png\", dpi=300, bbox_inches=\"tight\", facecolor=PAGE_BG)\n"}