{"spec_id":"rug-basic","library":"seaborn","language":"python","code":"\"\"\" anyplot.ai\nrug-basic: Basic Rug Plot\nLibrary: seaborn 0.13.2 | Python 3.13.14\nQuality: 89/100 | Updated: 2026-07-25\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\"\nBRAND = \"#009E73\"  # Imprint palette position 1 — ALWAYS first series\nAMBER = \"#DDCC77\"  # semantic caution anchor — flags outlier ticks\n\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.12,\n        \"legend.facecolor\": ELEVATED_BG,\n        \"legend.edgecolor\": INK_SOFT,\n    },\n)\n\n# Data - response times with bimodal pattern (fast and slow responses)\nnp.random.seed(42)\nfast_responses = np.random.normal(loc=150, scale=30, size=80)\nslow_responses = np.random.normal(loc=350, scale=50, size=40)\noutliers = np.array([50, 520, 550])\nresponse_times = np.concatenate([fast_responses, slow_responses, outliers])\n\n# Plot - KDE with rug plot beneath\nfig, ax = plt.subplots(figsize=(8, 4.5), dpi=400, facecolor=PAGE_BG)\nax.set_facecolor(PAGE_BG)\n\nsns.kdeplot(x=response_times, color=BRAND, linewidth=2.5, fill=True, alpha=0.28, ax=ax)\n# Main cluster ticks: taller + more opaque than the fill so they read distinctly on top of it\nsns.rugplot(x=np.concatenate([fast_responses, slow_responses]), height=0.08, lw=1.5, alpha=0.85, color=BRAND, ax=ax)\n# Outlier ticks called out in amber (caution anchor) — a focal point for the tail observations\nsns.rugplot(x=outliers, height=0.11, lw=2, alpha=0.9, color=AMBER, ax=ax)\n\n# Style\nax.set_xlabel(\"Response Time (ms)\", fontsize=10, color=INK)\nax.set_ylabel(\"Density\", fontsize=10, color=INK)\nax.set_title(\"rug-basic · python · seaborn · anyplot.ai\", fontsize=12, fontweight=\"medium\", color=INK)\nax.tick_params(axis=\"both\", labelsize=8, colors=INK_SOFT)\n\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\nax.yaxis.grid(True, alpha=0.12, linewidth=0.8, color=INK)\n\nplt.tight_layout()\nplt.savefig(f\"plot-{THEME}.png\", dpi=400, facecolor=PAGE_BG)\n"}