{"spec_id":"chessboard-basic","library":"plotly","language":"python","code":"\"\"\" anyplot.ai\nchessboard-basic: Chess Board Grid Visualization\nLibrary: plotly 6.7.0 | Python 3.13.13\nQuality: 80/100 | Updated: 2026-05-17\n\"\"\"\n\nimport numpy as np\nimport plotly.graph_objects as go\n\n\n# Data - 8x8 chess board\nrows = 8\ncols = 8\nrow_labels = [\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\"]\ncol_labels = [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"]\n\n# Create chess board pattern (0 = light, 1 = dark)\n# h1 should be light (white), so pattern starts with light at (0,7)\nboard = np.zeros((rows, cols))\nfor row in range(rows):\n    for col in range(cols):\n        # Light square when row+col is odd (to have h1 light)\n        board[row, col] = 0 if (row + col) % 2 == 1 else 1\n\n# Colors - classic cream and brown\nlight_color = \"#F0D9B5\"  # Cream\ndark_color = \"#B58863\"  # Brown\n\n# Create figure\nfig = go.Figure()\n\n# Add squares as shapes\nfor row in range(rows):\n    for col in range(cols):\n        color = light_color if board[row, col] == 0 else dark_color\n        fig.add_shape(\n            type=\"rect\", x0=col, y0=row, x1=col + 1, y1=row + 1, fillcolor=color, line=dict(color=\"#8B7355\", width=1)\n        )\n\n# Configure layout\nfig.update_layout(\n    title=dict(\n        text=\"chessboard-basic · plotly · pyplots.ai\", font=dict(size=32, color=\"#333333\"), x=0.5, xanchor=\"center\"\n    ),\n    xaxis=dict(\n        tickmode=\"array\",\n        tickvals=[i + 0.5 for i in range(cols)],\n        ticktext=col_labels,\n        tickfont=dict(size=24, color=\"#333333\"),\n        range=[0, 8],\n        showgrid=False,\n        zeroline=False,\n        side=\"bottom\",\n        constrain=\"domain\",\n    ),\n    yaxis=dict(\n        tickmode=\"array\",\n        tickvals=[i + 0.5 for i in range(rows)],\n        ticktext=row_labels,\n        tickfont=dict(size=24, color=\"#333333\"),\n        range=[0, 8],\n        showgrid=False,\n        zeroline=False,\n        scaleanchor=\"x\",\n        scaleratio=1,\n    ),\n    template=\"plotly_white\",\n    plot_bgcolor=\"white\",\n    paper_bgcolor=\"white\",\n    margin=dict(l=80, r=80, t=120, b=80),\n)\n\n# Save as PNG (3600x3600 for square aspect ratio)\nfig.write_image(\"plot.png\", width=1200, height=1200, scale=3)\n\n# Save interactive HTML\nfig.write_html(\"plot.html\")\n"}