{"spec_id":"surface-basic","library":"plotly","language":"python","code":"\"\"\" anyplot.ai\nsurface-basic: Basic 3D Surface Plot\nLibrary: plotly 6.7.0 | Python 3.13.13\nQuality: 93/100 | Updated: 2026-05-05\n\"\"\"\n\nimport os\n\nimport numpy as np\nimport plotly.graph_objects as go\n\n\n# Theme tokens\nTHEME = os.getenv(\"ANYPLOT_THEME\", \"light\")\nPAGE_BG = \"#FAF8F1\" if THEME == \"light\" else \"#1A1A17\"\nELEVATED_BG = \"#FFFDF6\" if THEME == \"light\" else \"#242420\"\nINK = \"#1A1A17\" if THEME == \"light\" else \"#F0EFE8\"\nINK_SOFT = \"#4A4A44\" if THEME == \"light\" else \"#B8B7B0\"\nGRID = \"rgba(26,26,23,0.10)\" if THEME == \"light\" else \"rgba(240,239,232,0.10)\"\n\n# Data - Create a smooth mathematical surface\nnp.random.seed(42)\nx = np.linspace(-5, 5, 40)\ny = np.linspace(-5, 5, 40)\nX, Y = np.meshgrid(x, y)\n\n# Create an interesting surface combining sinusoidal patterns\nZ = np.sin(np.sqrt(X**2 + Y**2)) * np.cos(X / 2) + 0.5 * np.exp(-0.1 * (X**2 + Y**2))\n\n# Plot\nfig = go.Figure(\n    data=[\n        go.Surface(\n            x=X,\n            y=Y,\n            z=Z,\n            colorscale=\"Viridis\",\n            colorbar={\n                \"title\": {\"text\": \"Z Value\", \"font\": {\"size\": 20, \"color\": INK}},\n                \"tickfont\": {\"size\": 16, \"color\": INK_SOFT},\n                \"len\": 0.7,\n            },\n        )\n    ]\n)\n\n# Style\nfig.update_layout(\n    title={\n        \"text\": \"surface-basic · plotly · anyplot.ai\",\n        \"font\": {\"size\": 28, \"color\": INK},\n        \"x\": 0.5,\n        \"xanchor\": \"center\",\n    },\n    scene={\n        \"xaxis\": {\n            \"title\": {\"text\": \"X Axis\", \"font\": {\"size\": 22, \"color\": INK}},\n            \"tickfont\": {\"size\": 18, \"color\": INK_SOFT},\n            \"gridcolor\": GRID,\n            \"showbackground\": True,\n            \"backgroundcolor\": PAGE_BG,\n        },\n        \"yaxis\": {\n            \"title\": {\"text\": \"Y Axis\", \"font\": {\"size\": 22, \"color\": INK}},\n            \"tickfont\": {\"size\": 18, \"color\": INK_SOFT},\n            \"gridcolor\": GRID,\n            \"showbackground\": True,\n            \"backgroundcolor\": PAGE_BG,\n        },\n        \"zaxis\": {\n            \"title\": {\"text\": \"Z Value\", \"font\": {\"size\": 22, \"color\": INK}},\n            \"tickfont\": {\"size\": 18, \"color\": INK_SOFT},\n            \"gridcolor\": GRID,\n            \"showbackground\": True,\n            \"backgroundcolor\": PAGE_BG,\n        },\n        \"camera\": {\"eye\": {\"x\": 1.5, \"y\": 1.5, \"z\": 1.2}},\n    },\n    paper_bgcolor=PAGE_BG,\n    plot_bgcolor=PAGE_BG,\n    margin={\"l\": 20, \"r\": 20, \"t\": 80, \"b\": 20},\n)\n\n# Save\nfig.write_image(f\"plot-{THEME}.png\", width=1600, height=900, scale=3)\nfig.write_html(f\"plot-{THEME}.html\", include_plotlyjs=\"cdn\")\n"}