{"spec_id":"chessboard-basic","library":"seaborn","language":"python","code":"\"\"\" anyplot.ai\nchessboard-basic: Chess Board Grid Visualization\nLibrary: seaborn 0.13.2 | Python 3.13.13\nQuality: 92/100 | Updated: 2026-05-17\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\"\nINK = \"#1A1A17\" if THEME == \"light\" else \"#F0EFE8\"\nINK_SOFT = \"#4A4A44\" if THEME == \"light\" else \"#B8B7B0\"\n\n# Chess colors - distinct from other libraries (cornsilk and sienna)\nLIGHT_SQUARE = \"#FFF8DC\"  # Cornsilk\nDARK_SQUARE = \"#A0522D\"  # Sienna\n\n# Data - Create 8x8 chessboard pattern\n# 0 = dark square, 1 = light square\n# Standard chess: h1 (bottom-right) is light\nboard = np.zeros((8, 8))\nfor i in range(8):\n    for j in range(8):\n        # Light square when (row + col) is even\n        if (i + j) % 2 == 0:\n            board[i, j] = 1\n\n# Column labels (a-h) and row labels (1-8)\ncolumns = list(\"abcdefgh\")\nrows = list(\"12345678\")[::-1]  # Reversed so 8 is at top\n\n# Set seaborn theme\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    },\n)\n\n# Create figure with 1:1 aspect ratio for square format\nfig, ax = plt.subplots(figsize=(12, 12), facecolor=PAGE_BG)\n\n# Plot heatmap using seaborn\nsns.heatmap(\n    board,\n    ax=ax,\n    cmap=[DARK_SQUARE, LIGHT_SQUARE],\n    cbar=False,\n    square=True,\n    linewidths=2,\n    linecolor=INK_SOFT,\n    xticklabels=columns,\n    yticklabels=rows,\n)\n\n# Style adjustments\nax.set_xlabel(\"File\", fontsize=20, color=INK)\nax.set_ylabel(\"Rank\", fontsize=20, color=INK)\nax.set_title(\"chessboard-basic · seaborn · anyplot.ai\", fontsize=24, fontweight=\"medium\", color=INK, pad=20)\n\n# Make tick labels larger and position them correctly\nax.tick_params(axis=\"both\", labelsize=16, length=0, colors=INK_SOFT)\nax.xaxis.set_ticks_position(\"bottom\")\nax.xaxis.set_label_position(\"bottom\")\n\n# Move x-axis ticks to center of squares\nax.set_xticks([i + 0.5 for i in range(8)])\nax.set_xticklabels(columns)\nax.set_yticks([i + 0.5 for i in range(8)])\nax.set_yticklabels(rows)\n\n# Set spine colors for theme\nfor spine in ax.spines.values():\n    spine.set_color(INK_SOFT)\n\nplt.tight_layout()\nplt.savefig(f\"plot-{THEME}.png\", dpi=300, bbox_inches=\"tight\", facecolor=PAGE_BG)\n"}