3D Line
Viviani's Curve
Viviani's curve - the intersection of a sphere and a cylinder passing through its center, in neon green.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
# Viviani curve - intersection of sphere and cylinder
n = 500
t = np.linspace(0, 4 * np.pi, n)
# Parametric equations for Viviani curve
a = 1
x = a * (1 + np.cos(t))
y = a * np.sin(t)
z = 2 * a * np.sin(t / 2)
fig = plt.figure(figsize=(10, 8), facecolor='#0a0a0f')
ax = fig.add_subplot(111, projection='3d', facecolor='#0a0a0f')
# Neon green glow
ax.plot(x, y, z, color='#22c55e', linewidth=5, alpha=0.2)
ax.plot(x, y, z, color='#4ade80', linewidth=2.5)
ax.plot(x, y, z, color='#86efac', linewidth=1)
ax.set_xlim(-0.5, 2.5)
ax.set_ylim(-1.5, 1.5)
ax.set_zlim(-2.5, 2.5)
ax.set_xlabel('X', color='white', fontsize=10)
ax.set_ylabel('Y', color='white', fontsize=10)
ax.set_zlabel('Z', color='white', fontsize=10)
ax.set_title("Viviani's Curve", color='white', fontsize=14, 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.grid(True, alpha=0.2, color='#334155')
ax.view_init(elev=25, azim=45)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
3D Charts
More 3D Line examples
☕