{"spec_id":"sudoku-basic","library":"matplotlib","language":"python","code":"\"\"\" anyplot.ai\nsudoku-basic: Basic Sudoku Grid\nLibrary: matplotlib 3.11.0 | Python 3.13.14\nQuality: 90/100 | Updated: 2026-06-25\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\"\nINK = \"#1A1A17\" if THEME == \"light\" else \"#F0EFE8\"\nINK_SOFT = \"#4A4A44\" if THEME == \"light\" else \"#B8B7B0\"\n\n# Data - A partially filled Sudoku puzzle (0 = empty cell)\ngrid = np.array(\n    [\n        [5, 3, 0, 0, 7, 0, 0, 0, 0],\n        [6, 0, 0, 1, 9, 5, 0, 0, 0],\n        [0, 9, 8, 0, 0, 0, 0, 6, 0],\n        [8, 0, 0, 0, 6, 0, 0, 0, 3],\n        [4, 0, 0, 8, 0, 3, 0, 0, 1],\n        [7, 0, 0, 0, 2, 0, 0, 0, 6],\n        [0, 6, 0, 0, 0, 0, 2, 8, 0],\n        [0, 0, 0, 4, 1, 9, 0, 0, 5],\n        [0, 0, 0, 0, 8, 0, 0, 7, 9],\n    ]\n)\n\n# Plot (square canvas: 2400×2400 px at dpi=400)\nfig, ax = plt.subplots(figsize=(6, 6), dpi=400, facecolor=PAGE_BG)\nax.set_facecolor(PAGE_BG)\nax.set_aspect(\"equal\")\nax.set_xlim(-0.1, 9.1)\nax.set_ylim(-0.1, 9.1)\n\n# Alternating 3×3 box shading (chess-board pattern) for visual navigation\nfor box_row in range(3):\n    for box_col in range(3):\n        if (box_row + box_col) % 2 == 1:\n            x0, x1 = box_col * 3, (box_col + 1) * 3\n            y0, y1 = box_row * 3, (box_row + 1) * 3\n            ax.fill([x0, x1, x1, x0], [y0, y0, y1, y1], color=INK, alpha=0.06, linewidth=0, zorder=0)\n\n# Inner thin lines for individual cell boundaries (skip box boundaries at 0,3,6,9)\nfor i in range(1, 9):\n    if i % 3 != 0:\n        ax.plot([0, 9], [i, i], color=INK_SOFT, linewidth=1.0, zorder=1, solid_capstyle=\"butt\")\n        ax.plot([i, i], [0, 9], color=INK_SOFT, linewidth=1.0, zorder=1, solid_capstyle=\"butt\")\n\n# Thick lines for 3×3 box boundaries with butt caps for crisp corners\nfor i in range(0, 10, 3):\n    ax.plot([0, 9], [i, i], color=INK, linewidth=3.5, zorder=2, solid_capstyle=\"butt\")\n    ax.plot([i, i], [0, 9], color=INK, linewidth=3.5, zorder=2, solid_capstyle=\"butt\")\n\n# Numbers centered in cells\nfor i in range(9):\n    for j in range(9):\n        value = grid[i, j]\n        if value != 0:\n            ax.text(\n                j + 0.5,\n                8 - i + 0.5,\n                str(value),\n                fontsize=28,\n                fontweight=\"bold\",\n                color=INK,\n                ha=\"center\",\n                va=\"center\",\n                zorder=3,\n            )\n\n# Hide axes, ticks, and spines (grid itself is the visual frame)\nax.set_xticks([])\nax.set_yticks([])\nfor spine in ax.spines.values():\n    spine.set_visible(False)\n\ntitle = \"sudoku-basic · python · matplotlib · anyplot.ai\"\ntitle_n = len(title)\ntitle_fontsize = max(8, round(12 * 67 / title_n)) if title_n > 67 else 12\nax.set_title(title, fontsize=title_fontsize, fontweight=\"medium\", color=INK, pad=14)\n\nplt.tight_layout()\nplt.savefig(f\"plot-{THEME}.png\", dpi=400, facecolor=PAGE_BG)\n"}