{"spec_id":"chessboard-basic","library":"pygal","language":"python","code":"\"\"\" anyplot.ai\nchessboard-basic: Chess Board Grid Visualization\nLibrary: pygal 3.1.0 | Python 3.13.13\nQuality: 85/100 | Updated: 2026-05-17\n\"\"\"\n\nimport pygal\nfrom pygal.style import Style\n\n\n# Chess board configuration\ncolumns = [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"]\n\n# Classic chess board colors\nlight_color = \"#F0D9B5\"  # Cream/tan for light squares\ndark_color = \"#B58863\"  # Brown for dark squares\n\n# Create the board using stacked bars\n# Each row is a horizontal bar with 8 stacked colored segments\nboard = pygal.StackedBar(\n    style=Style(\n        background=\"#FFFFFF\",\n        plot_background=\"#FFFFFF\",\n        foreground=\"#333333\",\n        foreground_strong=\"#333333\",\n        foreground_subtle=\"#555555\",\n        title_font_size=72,\n        label_font_size=52,\n        major_label_font_size=48,\n        legend_font_size=0,\n        value_font_size=0,\n        font_family=\"Arial\",\n        opacity=1.0,\n        opacity_hover=1.0,\n        transition=\"0s\",\n    ),\n    width=3600,\n    height=3600,\n    title=\"chessboard-basic · pygal · pyplots.ai\",\n    show_legend=False,\n    show_y_guides=False,\n    show_x_guides=False,\n    spacing=0,\n    margin=180,\n    margin_left=220,\n    print_values=False,\n    truncate_label=-1,\n    y_labels=[1, 2, 3, 4, 5, 6, 7, 8],\n    min_scale=1,\n)\n\n# X-axis labels (columns a-h at bottom)\nboard.x_labels = columns\n\n# For StackedBar, each add() creates a layer in the stack\n# We need 8 layers, each representing one \"row\" of the chessboard\n# The first add() is at the bottom, last at top\n\n# Build data for each row from row 1 (bottom) to row 8 (top)\nfor row_num in range(1, 9):\n    row_data = []\n    for col_idx in range(8):\n        # Standard chess: a1 is dark (col_idx=0, row=1: 0+1=1 odd -> dark)\n        # h1 is light (col_idx=7, row=1: 7+1=8 even -> light)\n        is_light = (col_idx + row_num) % 2 == 0\n\n        color = light_color if is_light else dark_color\n        row_data.append({\"value\": 1, \"color\": color})\n\n    board.add(str(row_num), row_data)\n\n# Render to files\nboard.render_to_file(\"plot.svg\")\nboard.render_to_png(\"plot.png\")\nboard.render_to_file(\"plot.html\")\n"}