{"spec_id":"contour-filled","library":"matplotlib","language":"python","code":"\"\"\" anyplot.ai\ncontour-filled: Filled Contour Plot\nLibrary: matplotlib 3.10.9 | Python 3.13.13\nQuality: 88/100 | Updated: 2026-05-11\n\"\"\"\n\nimport os\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\"\nELEVATED_BG = \"#FFFDF6\" if THEME == \"light\" else \"#242420\"\nINK = \"#1A1A17\" if THEME == \"light\" else \"#F0EFE8\"\nINK_SOFT = \"#4A4A44\" if THEME == \"light\" else \"#B8B7B0\"\n\n# Data - create a meshgrid with an interesting mathematical surface\nnp.random.seed(42)\nx = np.linspace(-3, 3, 80)\ny = np.linspace(-3, 3, 80)\nX, Y = np.meshgrid(x, y)\n\n# Create a surface with multiple Gaussian peaks and a saddle point\n# This demonstrates various features: peaks, valleys, and gradients\nZ = (\n    1.5 * np.exp(-((X - 1) ** 2 + (Y - 1) ** 2))\n    + 1.2 * np.exp(-((X + 1.5) ** 2 + (Y + 1) ** 2) / 1.5)\n    - 0.8 * np.exp(-((X + 0.5) ** 2 + (Y - 1.5) ** 2) / 0.8)\n    + 0.5 * np.exp(-((X - 1.5) ** 2 + (Y + 1.5) ** 2))\n)\n\n# Plot\nfig, ax = plt.subplots(figsize=(16, 9), facecolor=PAGE_BG)\nax.set_facecolor(PAGE_BG)\n\n# Create filled contour plot with sequential colormap\nlevels = 15\ncontourf = ax.contourf(X, Y, Z, levels=levels, cmap=\"viridis\")\n\n# Overlay contour lines for level identification\nax.contour(X, Y, Z, levels=levels, colors=INK_SOFT, linewidths=0.8, alpha=0.4)\n\n# Add colorbar\ncbar = plt.colorbar(contourf, ax=ax, shrink=0.9, pad=0.02)\ncbar.set_label(\"Surface Value\", fontsize=20, color=INK)\ncbar.ax.tick_params(labelsize=16, colors=INK_SOFT)\n\n# Style\nax.set_xlabel(\"X Coordinate\", fontsize=20, color=INK)\nax.set_ylabel(\"Y Coordinate\", fontsize=20, color=INK)\nax.set_title(\"contour-filled · matplotlib · anyplot.ai\", fontsize=24, fontweight=\"medium\", color=INK)\nax.tick_params(axis=\"both\", labelsize=16, colors=INK_SOFT)\n\n# Set equal aspect ratio for proper visualization\nax.set_aspect(\"equal\", adjustable=\"box\")\n\n# Style spines\nfor spine in (\"top\", \"right\", \"left\", \"bottom\"):\n    ax.spines[spine].set_color(INK_SOFT)\n    ax.spines[spine].set_linewidth(0.8)\n\nplt.tight_layout()\nplt.savefig(f\"plot-{THEME}.png\", dpi=300, bbox_inches=\"tight\", facecolor=PAGE_BG)\n"}