3D Surface
Boy Surface Immersion
Immersion of the real projective plane without triple points in purple-pink gradient.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.colors import LinearSegmentedColormap
# Boy's surface parametrization (Bryant-Kusner)
u = np.linspace(0, np.pi, 80)
v = np.linspace(0, np.pi, 80)
u, v = np.meshgrid(u, v)
# Complex coordinates
z1 = np.cos(u) * np.cos(v) + 1j * np.cos(u) * np.sin(v)
z2 = np.sin(u) * np.cos(2*v) + 1j * np.sin(u) * np.sin(2*v)
g1 = -1.5 * np.imag(z1 / (1 - z2**2))
g2 = -1.5 * np.real(z1 / (1 - z2**2))
g3 = np.imag((z1**2 - z2) / (1 - z2**2)) - 0.5
x = g1 / (g1**2 + g2**2 + g3**2 + 1)
y = g2 / (g1**2 + g2**2 + g3**2 + 1)
z = g3 / (g1**2 + g2**2 + g3**2 + 1)
# Custom colormap
colors = ['#ffffff', '#fae8ff', '#4927F5', '#F527B0', '#fda4af']
cmap = LinearSegmentedColormap.from_list('purple_pink', colors, N=256)
fig = plt.figure(figsize=(10, 8), facecolor='#ffffff')
ax = fig.add_subplot(111, projection='3d', facecolor='#ffffff')
surf = ax.plot_surface(x, y, z, cmap=cmap, alpha=0.85, linewidth=0.1, edgecolor='#33333315')
ax.set_xlabel('X', fontsize=10, color='#374151', labelpad=10)
ax.set_ylabel('Y', fontsize=10, color='#374151', labelpad=10)
ax.set_zlabel('Z', fontsize=10, color='#374151', labelpad=10)
ax.set_title("Boy Surface Immersion", 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=20, azim=45)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
3D Charts
More 3D Surface examples
☕