Basic 3D Surface Plot — Seaborn

A 3D surface plot visualizes a function of two variables as a continuous surface in three-dimensional space. The height (z-axis) represents the function value at each (x, y) point, with color encoding the same information to enhance depth perception. This visualization is ideal for understanding mathematical functions, terrain data, and response surfaces where the relationship between two inputs and one output needs to be explored.

Basic 3D Surface Plot rendered with Seaborn

Renders

Python source (Seaborn)

""" anyplot.ai
surface-basic: Basic 3D Surface Plot
Library: seaborn 0.13.2 | Python 3.13.13
Quality: 85/100 | Created: 2026-05-05
"""

import os
import sys


sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)) + "/../../../../.venv/lib/python3.13/site-packages")

import matplotlib.pyplot as plt
import numpy as np


# Theme tokens
THEME = os.getenv("ANYPLOT_THEME", "light")
PAGE_BG = "#FAF8F1" if THEME == "light" else "#1A1A17"
INK = "#1A1A17" if THEME == "light" else "#F0EFE8"
INK_SOFT = "#4A4A44" if THEME == "light" else "#B8B7B0"

# Data
np.random.seed(42)
x = np.linspace(-5, 5, 40)
y = np.linspace(-5, 5, 40)
X, Y = np.meshgrid(x, y)
Z = np.sin(np.sqrt(X**2 + Y**2)) * np.exp(-0.1 * (X**2 + Y**2))

# Plot
fig = plt.figure(figsize=(16, 9), facecolor=PAGE_BG)
ax = fig.add_subplot(111, projection="3d")
ax.set_facecolor(PAGE_BG)

surf = ax.plot_surface(X, Y, Z, cmap="viridis", alpha=0.95, edgecolor="none")

# Style
ax.set_xlabel("X", fontsize=20, color=INK, labelpad=15)
ax.set_ylabel("Y", fontsize=20, color=INK, labelpad=15)
ax.set_zlabel("Z", fontsize=20, color=INK, labelpad=15)
ax.set_title("surface-basic · seaborn · anyplot.ai", fontsize=24, fontweight="medium", color=INK, pad=20)

ax.tick_params(axis="both", labelsize=14, colors=INK_SOFT)
for spine in ax.spines.values():
    spine.set_edgecolor(INK_SOFT)
ax.grid(False)

# Colorbar
cbar = fig.colorbar(surf, ax=ax, pad=0.1, shrink=0.8)
cbar.set_label("Height", fontsize=16, color=INK, labelpad=10)
cbar.ax.tick_params(labelsize=14, colors=INK_SOFT)

ax.view_init(elev=25, azim=45)

plt.tight_layout()
plt.savefig(f"plot-{THEME}.png", dpi=300, bbox_inches="tight", facecolor=PAGE_BG)
plt.close()

Retrieve this implementation

Runnable source as JSON, for any HTTP client: https://api.anyplot.ai/specs/surface-basic/seaborn/code. Any spec id and library id listed in llms-full.txt fit the same URL shape; every URL below is complete and callable.

{
  "spec_id": "surface-basic",
  "language": "python",
  "library": "seaborn",
  "page": "https://anyplot.ai/surface-basic/python/seaborn",
  "hub": "https://anyplot.ai/surface-basic",
  "code_json": "https://api.anyplot.ai/specs/surface-basic/seaborn/code",
  "spec_json": "https://api.anyplot.ai/specs/surface-basic",
  "render_light_png": "https://storage.googleapis.com/anyplot-images/plots/surface-basic/python/seaborn/plot-light.png",
  "render_dark_png": "https://storage.googleapis.com/anyplot-images/plots/surface-basic/python/seaborn/plot-dark.png",
  "quality_score": 85.0,
  "license": "MIT",
  "guide": "https://anyplot.ai/llms.txt"
}

Part of Basic 3D Surface Plot on anyplot.ai.

Other implementations