{"spec_id":"box-horizontal","library":"seaborn","language":"python","code":"\"\"\" anyplot.ai\nbox-horizontal: Horizontal Box Plot\nLibrary: seaborn 0.13.2 | Python 3.13.13\nQuality: 90/100 | Updated: 2026-05-12\n\"\"\"\n\nimport os\n\nimport matplotlib.pyplot as plt\nimport numpy as np\nimport pandas as pd\nimport seaborn as sns\n\n\n# Theme tokens (see prompts/default-style-guide.md \"Background\" + \"Theme-adaptive Chrome\")\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 — ALWAYS first series\n\n# Data - salary ranges by job title (with realistic distributions)\nnp.random.seed(42)\n\ncategories = [\"Software Engineer\", \"Product Manager\", \"Data Scientist\", \"UX Designer\", \"DevOps Engineer\"]\n\ndata = []\n# Software Engineer - moderate spread\ndata.extend(\n    [\n        {\"Job Title\": \"Software Engineer\", \"Salary (USD)\": v}\n        for v in np.concatenate(\n            [\n                np.random.normal(135000, 25000, 80),\n                np.random.normal(200000, 15000, 5),  # outliers (senior/staff)\n            ]\n        )\n    ]\n)\n\n# Product Manager - higher median with tight distribution\ndata.extend([{\"Job Title\": \"Product Manager\", \"Salary (USD)\": v} for v in np.random.normal(155000, 22000, 85)])\n\n# Data Scientist - wide spread with high values\ndata.extend(\n    [\n        {\"Job Title\": \"Data Scientist\", \"Salary (USD)\": v}\n        for v in np.concatenate(\n            [\n                np.random.normal(145000, 30000, 75),\n                np.random.normal(220000, 20000, 10),  # outliers\n            ]\n        )\n    ]\n)\n\n# UX Designer - moderate values\ndata.extend([{\"Job Title\": \"UX Designer\", \"Salary (USD)\": v} for v in np.random.normal(120000, 20000, 85)])\n\n# DevOps Engineer - highest median, tight distribution\ndata.extend([{\"Job Title\": \"DevOps Engineer\", \"Salary (USD)\": v} for v in np.random.normal(160000, 18000, 90)])\n\ndf = pd.DataFrame(data)\n\n# Sort categories by median for easier comparison\ncategory_order = df.groupby(\"Job Title\")[\"Salary (USD)\"].median().sort_values().index.tolist()\n\n# Set theme-adaptive styling\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        \"legend.facecolor\": ELEVATED_BG,\n        \"legend.edgecolor\": INK_SOFT,\n    },\n)\n\n# Create figure\nfig, ax = plt.subplots(figsize=(16, 9), facecolor=PAGE_BG)\n\n# Horizontal box plot with single color\nsns.boxplot(\n    data=df,\n    x=\"Salary (USD)\",\n    y=\"Job Title\",\n    order=category_order,\n    color=BRAND,\n    linewidth=2,\n    width=0.6,\n    flierprops={\"marker\": \"o\", \"markersize\": 8, \"alpha\": 0.6},\n    ax=ax,\n)\n\n# Labels and styling\nax.set_xlabel(\"Salary (USD)\", fontsize=20, color=INK)\nax.set_ylabel(\"Job Title\", fontsize=20, color=INK)\nax.set_title(\"box-horizontal · seaborn · anyplot.ai\", fontsize=24, fontweight=\"medium\", color=INK)\nax.tick_params(axis=\"both\", labelsize=16, colors=INK_SOFT)\n\n# Spine styling\nax.spines[\"top\"].set_visible(False)\nax.spines[\"right\"].set_visible(False)\nfor spine in (\"left\", \"bottom\"):\n    ax.spines[spine].set_color(INK_SOFT)\n\n# Grid styling - subtle on x-axis only\nax.xaxis.grid(True, alpha=0.10, linewidth=0.8, color=INK)\nax.yaxis.grid(False)\n\n# Adjust layout\nplt.tight_layout()\nplt.savefig(f\"plot-{THEME}.png\", dpi=300, bbox_inches=\"tight\", facecolor=PAGE_BG)\n"}