3D Trisurf

Gaussian Mixture Model Trisurf

Three-component Gaussian mixture density from scattered sampling in coral-magenta gradient.

Output
Gaussian Mixture Model Trisurf
Python
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.colors import LinearSegmentedColormap

# Scattered sampling
np.random.seed(66)
n_points = 700
x = np.random.uniform(-4, 4, n_points)
y = np.random.uniform(-4, 4, n_points)

# Three Gaussian components
def gaussian_2d(x, y, mx, my, sx, sy):
    return np.exp(-((x-mx)**2/(2*sx**2) + (y-my)**2/(2*sy**2)))

z = (0.4 * gaussian_2d(x, y, -1.5, 0, 0.8, 1.0) +
     0.35 * gaussian_2d(x, y, 1.5, 1, 1.0, 0.7) +
     0.25 * gaussian_2d(x, y, 0.5, -1.5, 0.6, 0.9))

# Custom colormap
colors = ['#0a0a0f', '#4a1942', '#F5276C', '#ec4899', '#fda4af']
cmap = LinearSegmentedColormap.from_list('coral_magenta', colors, N=256)

fig = plt.figure(figsize=(10, 8), facecolor='#0a0a0f')
ax = fig.add_subplot(111, projection='3d', facecolor='#0a0a0f')

surf = ax.plot_trisurf(x, y, z, cmap=cmap, alpha=0.9, linewidth=0.1, edgecolor='#ffffff08')

ax.set_xlabel('X', fontsize=10, color='#94a3b8', labelpad=10)
ax.set_ylabel('Y', fontsize=10, color='#94a3b8', labelpad=10)
ax.set_zlabel('Density', fontsize=10, color='#94a3b8', labelpad=10)
ax.set_title("Gaussian Mixture Model Trisurf", fontsize=14, color='white', fontweight='bold', pad=20)

ax.tick_params(colors='#64748b', labelsize=8)
ax.xaxis.pane.fill = False
ax.yaxis.pane.fill = False
ax.zaxis.pane.fill = False
ax.xaxis.pane.set_edgecolor('#1e293b')
ax.yaxis.pane.set_edgecolor('#1e293b')
ax.zaxis.pane.set_edgecolor('#1e293b')

ax.view_init(elev=30, azim=45)
plt.tight_layout()
plt.show()
Library

Matplotlib

Category

3D Charts

Did this help you?

Support PyLucid to keep it free & growing

Support