3D Trisurf
EM Field Potential Trisurf
Electric potential field from two charges visualized from scattered points in mint-purple gradient.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.colors import LinearSegmentedColormap
# Scattered points
np.random.seed(66)
n_points = 600
x = np.random.uniform(-3, 3, n_points)
y = np.random.uniform(-3, 3, n_points)
# Two charges potential
r1 = np.sqrt((x - 1)**2 + y**2 + 0.5)
r2 = np.sqrt((x + 1)**2 + y**2 + 0.5)
z = 1/r1 - 1/r2
z = np.clip(z, -3, 3)
# Custom colormap
colors = ['#0a0a0f', '#042f2e', '#27F5B0', '#4927F5', '#c4b5fd']
cmap = LinearSegmentedColormap.from_list('mint_purple', 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('Potential', fontsize=10, color='#94a3b8', labelpad=10)
ax.set_title("EM Field Potential 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=25, azim=45)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
3D Charts
More 3D Trisurf examples
☕