{"spec_id":"chessboard-basic","library":"letsplot","language":"python","code":"\"\"\" anyplot.ai\nchessboard-basic: Chess Board Grid Visualization\nLibrary: letsplot 4.9.0 | Python 3.13.13\nQuality: 87/100 | Updated: 2026-05-17\n\"\"\"\n\nimport os\nimport shutil\n\nimport pandas as pd\nfrom lets_plot import (\n    LetsPlot,\n    aes,\n    coord_fixed,\n    element_blank,\n    element_text,\n    geom_tile,\n    ggplot,\n    ggsave,\n    ggsize,\n    labs,\n    scale_fill_manual,\n    scale_x_discrete,\n    scale_y_discrete,\n    theme,\n)\n\n\nLetsPlot.setup_html()\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\ncolumns = list(\"abcdefgh\")\nrows = list(range(1, 9))\n\ndata = []\nfor col_idx, col in enumerate(columns):\n    for row_idx, row in enumerate(rows):\n        is_light = (col_idx + row_idx) % 2 == 1\n        data.append({\"column\": col, \"row\": str(row), \"color\": \"light\" if is_light else \"dark\"})\n\ndf = pd.DataFrame(data)\n\n# Create the chess board visualization\nplot = (\n    ggplot(df, aes(x=\"column\", y=\"row\", fill=\"color\"))\n    + geom_tile(color=\"#5D4037\", size=0.5)\n    + scale_fill_manual(values={\"light\": \"#F5DEB3\", \"dark\": \"#8B4513\"})\n    + scale_x_discrete(limits=columns)\n    + scale_y_discrete(limits=[str(r) for r in rows])\n    + coord_fixed(ratio=1)\n    + labs(title=\"chessboard-basic · letsplot · anyplot.ai\")\n    + theme(\n        plot_background=element_blank(),\n        panel_background=element_blank(),\n        panel_grid=element_blank(),\n        plot_title=element_text(size=24, color=INK),\n        axis_title=element_blank(),\n        axis_text_x=element_text(size=20, color=INK_SOFT),\n        axis_text_y=element_text(size=20, color=INK_SOFT),\n        legend_position=\"none\",\n    )\n    + ggsize(1200, 1200)\n)\n\n# Save as PNG and HTML with theme-suffixed filenames\nggsave(plot, f\"plot-{THEME}.png\", scale=3)\nggsave(plot, f\"plot-{THEME}.html\")\n\nif os.path.exists(f\"lets-plot-images/plot-{THEME}.png\"):\n    shutil.move(f\"lets-plot-images/plot-{THEME}.png\", f\"plot-{THEME}.png\")\nif os.path.exists(f\"lets-plot-images/plot-{THEME}.html\"):\n    shutil.move(f\"lets-plot-images/plot-{THEME}.html\", f\"plot-{THEME}.html\")\n"}