{"spec_id":"chessboard-basic","library":"plotnine","language":"python","code":"\"\"\" anyplot.ai\nchessboard-basic: Chess Board Grid Visualization\nLibrary: plotnine 0.15.4 | Python 3.13.13\nQuality: 94/100 | Updated: 2026-05-17\n\"\"\"\n\nimport os\n\nimport pandas as pd\nfrom plotnine import (\n    aes,\n    coord_fixed,\n    element_blank,\n    element_rect,\n    element_text,\n    geom_tile,\n    ggplot,\n    labs,\n    scale_fill_manual,\n    scale_x_continuous,\n    scale_y_continuous,\n    theme,\n)\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 - create 8x8 chess board grid\nrows = list(range(1, 9))\ncols = list(range(1, 9))\ncol_labels = [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"]\n\n# Create grid data\ndata = []\nfor row in rows:\n    for col in cols:\n        # Light squares where (row + col) is even, dark where odd\n        # This ensures h1 (row=1, col=8) is light: 1+8=9 is odd, so we flip\n        is_light = (row + col) % 2 == 1\n        data.append({\"col\": col, \"row\": row, \"color\": \"light\" if is_light else \"dark\"})\n\ndf = pd.DataFrame(data)\n\n# Chess board colors - classic cream and brown\nlight_color = \"#F0D9B5\"\ndark_color = \"#B58863\"\n\n# Create plot\nplot = (\n    ggplot(df, aes(x=\"col\", y=\"row\", fill=\"color\"))\n    + geom_tile(color=INK_SOFT, size=0.3)\n    + scale_fill_manual(values={\"light\": light_color, \"dark\": dark_color})\n    + scale_x_continuous(breaks=list(range(1, 9)), labels=col_labels, expand=(0, 0))\n    + scale_y_continuous(breaks=list(range(1, 9)), labels=[str(i) for i in range(1, 9)], expand=(0, 0))\n    + coord_fixed(ratio=1)\n    + labs(x=\"Column\", y=\"Row\", title=\"chessboard-basic · plotnine · anyplot.ai\")\n    + theme(\n        figure_size=(9, 9),\n        plot_title=element_text(size=24, ha=\"center\", weight=\"bold\", color=INK),\n        axis_title=element_text(size=20, color=INK),\n        axis_text_x=element_text(size=20, weight=\"bold\", color=INK_SOFT),\n        axis_text_y=element_text(size=20, weight=\"bold\", color=INK_SOFT),\n        axis_ticks=element_blank(),\n        panel_background=element_rect(fill=PAGE_BG),\n        panel_grid_major=element_blank(),\n        panel_grid_minor=element_blank(),\n        legend_position=\"none\",\n        plot_background=element_rect(fill=PAGE_BG, color=PAGE_BG),\n        panel_border=element_rect(color=INK_SOFT, size=2),\n    )\n)\n\n# Save\nplot.save(f\"plot-{THEME}.png\", dpi=300, width=9, height=9)\n"}