{"spec_id":"chessboard-basic","library":"matplotlib","language":"python","code":"\"\"\" anyplot.ai\nchessboard-basic: Chess Board Grid Visualization\nLibrary: matplotlib 3.10.9 | Python 3.13.13\nQuality: 92/100 | Updated: 2026-05-17\n\"\"\"\n\nimport os\nimport sys\n\n\n# Remove the script directory from sys.path to avoid shadowing the matplotlib package\nsys.path = [p for p in sys.path if p != os.path.dirname(__file__)]\n\nimport matplotlib.pyplot as plt\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# Chess board colors (theme-adaptive)\nif THEME == \"light\":\n    LIGHT_SQUARE = \"#F0D9B5\"\n    DARK_SQUARE = \"#B58863\"\n    BORDER_COLOR = \"#5D4037\"\nelse:\n    LIGHT_SQUARE = \"#E8D4C4\"\n    DARK_SQUARE = \"#6B5047\"\n    BORDER_COLOR = \"#A0967C\"\n\n# Board configuration\nrows = 8\ncols = 8\ncolumn_labels = [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"]\nrow_labels = [\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\"]\n\n# Create figure (square aspect ratio for chess board)\nfig, ax = plt.subplots(figsize=(12, 12), facecolor=PAGE_BG)\nax.set_facecolor(PAGE_BG)\n\n# Draw the chess board squares\nfor row in range(rows):\n    for col in range(cols):\n        # h1 (col=7, row=0) should be light, so (row + col) even = light\n        color = LIGHT_SQUARE if (row + col) % 2 == 1 else DARK_SQUARE\n        rect = plt.Rectangle((col, row), 1, 1, facecolor=color, edgecolor=BORDER_COLOR, linewidth=1)\n        ax.add_patch(rect)\n\n# Set axis limits\nax.set_xlim(0, 8)\nax.set_ylim(0, 8)\n\n# Set column labels (a-h) at the bottom\nax.set_xticks([i + 0.5 for i in range(8)])\nax.set_xticklabels(column_labels, fontsize=20, fontweight=\"bold\", color=INK)\n\n# Set row labels (1-8) on the left side\nax.set_yticks([i + 0.5 for i in range(8)])\nax.set_yticklabels(row_labels, fontsize=20, fontweight=\"bold\", color=INK)\n\n# Style the axis\nax.tick_params(axis=\"both\", length=0, pad=10)\nax.set_aspect(\"equal\")\n\n# Remove spines and add a border\nfor spine in ax.spines.values():\n    spine.set_visible(True)\n    spine.set_linewidth(3)\n    spine.set_color(BORDER_COLOR)\n\n# Title\nax.set_title(\"chessboard-basic · matplotlib · anyplot.ai\", fontsize=24, fontweight=\"bold\", color=INK, pad=20)\n\nplt.tight_layout()\nplt.savefig(f\"plot-{THEME}.png\", dpi=300, bbox_inches=\"tight\", facecolor=PAGE_BG)\n"}