{"spec_id":"area-mountain-panorama","library":"matplotlib","language":"python","code":"\"\"\" anyplot.ai\narea-mountain-panorama: Mountain Panorama Profile with Labeled Peaks\nLibrary: matplotlib 3.11.0 | Python 3.13.14\nQuality: 86/100 | Updated: 2026-06-30\n\"\"\"\n\nimport os\n\nimport matplotlib.pyplot as plt\nimport numpy as np\nfrom matplotlib.colors import LinearSegmentedColormap\n\n\n# Theme-adaptive chrome tokens (Imprint palette)\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\"\nINK_MUTED = \"#6B6A63\" if THEME == \"light\" else \"#A8A79F\"\nBRAND = \"#009E73\"  # Imprint palette position 1\nSKY_TOP = \"#E8C8A0\" if THEME == \"light\" else \"#252D40\"\n# Dark silhouette fill: very dark near-black for photo-like alpine silhouette\nMOUNTAIN_FILL = \"#23231F\" if THEME == \"light\" else \"#0D0D0B\"\n\n# Data — Wallis (Valais) summit panorama, ordered W → E\npeaks = [\n    (\"Weisshorn\", 12, 4506),\n    (\"Zinalrothorn\", 30, 4221),\n    (\"Ober Gabelhorn\", 45, 4063),\n    (\"Dent Blanche\", 58, 4358),\n    (\"Dent d'Hérens\", 76, 4171),\n    (\"Matterhorn\", 92, 4478),\n    (\"Breithorn\", 120, 4164),\n    (\"Pollux\", 132, 4092),\n    (\"Castor\", 139, 4223),\n    (\"Liskamm\", 152, 4527),\n    (\"Monte Rosa\", 170, 4634),\n    (\"Strahlhorn\", 192, 4190),\n    (\"Rimpfischhorn\", 204, 4199),\n    (\"Allalinhorn\", 215, 4027),\n    (\"Alphubel\", 225, 4206),\n    (\"Täschhorn\", 236, 4491),\n    (\"Dom\", 250, 4545),\n]\n\n# Top 3 summits by elevation for additional visual emphasis\ntop_elevations = set(sorted([p[2] for p in peaks], reverse=True)[:3])  # 4634, 4545, 4527\n\n# Skyline construction — piecewise-linear triangular tent peaks (NOT Gaussian)\nnp.random.seed(42)\nn_pts = 2000\nangle = np.linspace(0, 262, n_pts)\n\n# Base ridge: smoothed random walk in the 3000–3700 m belt (foothills + minor cols)\nwalk = np.cumsum(np.random.randn(n_pts) * 1.5)\nsigma_walk = 22\ng = np.arange(-3 * sigma_walk, 3 * sigma_walk + 1)\nkernel_walk = np.exp(-(g**2) / (2 * sigma_walk**2))\nwalk = np.convolve(walk, kernel_walk / kernel_walk.sum(), mode=\"same\")\nwalk = (walk - walk.min()) / (walk.max() - walk.min())\nridge = 3000 + walk * 700\n\n# Asymmetric triangular tent functions — steep linear flanks, sharp pointed apexes\nfor _, pos, elev in peaks:\n    col_base = max(elev - np.random.uniform(900, 1300), 2900)\n    left_w = np.random.uniform(5.0, 8.5)  # asymmetric half-widths in degrees\n    right_w = np.random.uniform(7.0, 11.5)\n\n    tent = np.zeros(n_pts)\n    mask_l = (angle >= pos - left_w) & (angle < pos)\n    if mask_l.any():\n        t_l = (angle[mask_l] - (pos - left_w)) / left_w\n        tent[mask_l] = col_base + t_l * (elev - col_base)\n    mask_r = (angle > pos) & (angle <= pos + right_w)\n    if mask_r.any():\n        t_r = 1.0 - (angle[mask_r] - pos) / right_w\n        tent[mask_r] = col_base + t_r * (elev - col_base)\n    apex_idx = int(np.argmin(np.abs(angle - pos)))\n    tent[apex_idx] = elev\n\n    ridge = np.maximum(ridge, tent)\n\n# Rocky jaggedness: lightly smoothed high-frequency noise for rugged alpine texture\nrock_noise = np.random.randn(n_pts) * 22\nsigma_r = 1.5\ng2 = np.arange(-5, 6)\nk2 = np.exp(-(g2**2) / (2 * sigma_r**2))\nrock_noise = np.convolve(rock_noise, k2 / k2.sum(), mode=\"same\")\nridge = ridge + rock_noise\n\n# Re-pin apex elevations after noise (labeled summits show their true height)\nfor _, pos, elev in peaks:\n    apex_idx = int(np.argmin(np.abs(angle - pos)))\n    ridge[apex_idx] = max(ridge[apex_idx], elev)\n\n# Canvas — landscape 3200×1800 px (figsize=(8, 4.5) × dpi=400)\nfig, ax = plt.subplots(figsize=(8, 4.5), dpi=400, facecolor=PAGE_BG)\nax.set_facecolor(PAGE_BG)\n\n# Sky gradient above ridgeline (dusk mood: warm peach for light, deep navy for dark)\nsky_cmap = LinearSegmentedColormap.from_list(\"sky\", [PAGE_BG, SKY_TOP])\nsky_gradient = np.linspace(0, 1, 256).reshape(-1, 1)\nax.imshow(\n    sky_gradient,\n    extent=(0, 262, 2400, 6050),\n    aspect=\"auto\",\n    cmap=sky_cmap,\n    origin=\"lower\",\n    zorder=1,\n    interpolation=\"bilinear\",\n)\n\n# Mountain silhouette — dark solid fill (photo-like silhouette, evening/dusk feel)\nax.fill_between(angle, 2400, ridge, color=MOUNTAIN_FILL, linewidth=0, zorder=2)\n# Brand-green ridge highlight line for identity against the dark mountain body\nax.plot(angle, ridge, color=BRAND, linewidth=1.0, alpha=0.7, zorder=3)\n\n# Peak labels staggered across three vertical levels with thin leader lines\nlabel_levels = [5050, 5310, 5570]\nsorted_peaks = sorted(peaks, key=lambda p: p[1])\nfor i, (name, pos, elev) in enumerate(sorted_peaks):\n    level = label_levels[i % 3]\n    is_anchor = name == \"Matterhorn\"\n    is_top = elev in top_elevations\n\n    if is_anchor:\n        text_color = INK\n        text_weight = \"bold\"\n        line_color = INK\n        line_alpha = 0.85\n        line_width = 1.2\n        fsize = 10\n    elif is_top:\n        text_color = INK_SOFT\n        text_weight = \"semibold\"\n        line_color = INK_SOFT\n        line_alpha = 0.65\n        line_width = 0.9\n        fsize = 9\n    else:\n        text_color = INK_SOFT\n        text_weight = \"regular\"\n        line_color = INK_SOFT\n        line_alpha = 0.45\n        line_width = 0.7\n        fsize = 8\n\n    ax.plot([pos, pos], [elev + 20, level - 50], color=line_color, linewidth=line_width, alpha=line_alpha, zorder=4)\n    ax.text(\n        pos,\n        level,\n        f\"{name}\\n{elev:,} m\",\n        ha=\"center\",\n        va=\"bottom\",\n        fontsize=fsize,\n        fontweight=text_weight,\n        color=text_color,\n        linespacing=1.3,\n        zorder=5,\n    )\n\n# Axes\nax.set_ylim(2500, 6050)\nax.set_xlim(0, 262)\nax.set_ylabel(\"Elevation (m)\", fontsize=10, color=INK)\n\ntitle = \"Wallis Alps · area-mountain-panorama · matplotlib · anyplot.ai\"\ntitle_fontsize = max(8, round(12 * 67 / len(title))) if len(title) > 67 else 12\nax.set_title(title, fontsize=title_fontsize, fontweight=\"medium\", color=INK, pad=10)\n\n# Compass bearings on x-axis\ncompass_ticks = [10, 65, 120, 180, 245]\ncompass_labels = [\"W\", \"SW\", \"S\", \"SE\", \"E\"]\nax.set_xticks(compass_ticks)\nax.set_xticklabels(compass_labels, fontsize=8, color=INK_SOFT)\nax.tick_params(axis=\"x\", colors=INK_SOFT, length=0)\nax.tick_params(axis=\"y\", labelsize=8, colors=INK_SOFT, labelcolor=INK_SOFT)\n\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.10, linewidth=0.6, color=INK)\n\nplt.tight_layout(pad=0.8)\nplt.savefig(f\"plot-{THEME}.png\", dpi=400, facecolor=PAGE_BG)\n"}