3D Trisurf
ML Hyperparameter Surface
Machine learning hyperparameter optimization landscape visualization in teal-purple gradient.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.colors import LinearSegmentedColormap
# Parameter space sampling
np.random.seed(99)
n_points = 700
x = np.random.uniform(-3, 3, n_points)
y = np.random.uniform(-3, 3, n_points)
# Complex loss landscape with local minima
z = (0.5 * (x**2 + y**2) +
2 * np.exp(-((x-1)**2 + (y-1)**2)/0.5) +
1.5 * np.exp(-((x+1.5)**2 + (y-1)**2)/0.3) +
0.5 * np.sin(2*x) * np.cos(2*y))
# Custom colormap
colors = ['#ffffff', '#ccfbf1', '#14b8a6', '#4927F5', '#a78bfa']
cmap = LinearSegmentedColormap.from_list('teal_purple', colors, N=256)
fig = plt.figure(figsize=(10, 8), facecolor='#ffffff')
ax = fig.add_subplot(111, projection='3d', facecolor='#ffffff')
surf = ax.plot_trisurf(x, y, z, cmap=cmap, alpha=0.85, linewidth=0.1, edgecolor='#33333308')
ax.set_xlabel('Learning Rate', fontsize=10, color='#374151', labelpad=10)
ax.set_ylabel('Regularization', fontsize=10, color='#374151', labelpad=10)
ax.set_zlabel('Validation Loss', fontsize=10, color='#374151', labelpad=10)
ax.set_title("ML Hyperparameter Surface", fontsize=14, color='#1f2937', fontweight='bold', pad=20)
ax.tick_params(colors='#6b7280', labelsize=8)
ax.xaxis.pane.fill = False
ax.yaxis.pane.fill = False
ax.zaxis.pane.fill = False
ax.xaxis.pane.set_edgecolor('#e5e7eb')
ax.yaxis.pane.set_edgecolor('#e5e7eb')
ax.zaxis.pane.set_edgecolor('#e5e7eb')
ax.view_init(elev=30, azim=135)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
3D Charts
More 3D Trisurf examples
☕