3D Fill Between

3D Electromagnetic Field Lines

Physics visualization of electromagnetic field lines between two poles with neon aesthetic.

Output
3D Electromagnetic Field Lines
Python
import matplotlib.pyplot as plt
import numpy as np

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

n_lines = 12
theta = np.linspace(0, 2*np.pi, n_lines, endpoint=False)

for th in theta:
    t = np.linspace(0, np.pi, 100)
    r = 2 * np.sin(t)
    
    x = r * np.cos(th)
    y = r * np.sin(th)
    z = 2 * np.cos(t)
    
    # Outer field line
    ax.plot(x, y, z, linewidth=2, color='#F5B027', alpha=0.8)
    
    # Inner field line
    x_inner = 0.6 * r * np.cos(th)
    y_inner = 0.6 * r * np.sin(th)
    z_inner = 1.5 * np.cos(t)
    ax.plot(x_inner, y_inner, z_inner, linewidth=1.5, color='#27D3F5', alpha=0.8)
    
    # Connect lines
    for i in range(0, len(t), 15):
        ax.plot([x[i], x_inner[i]], [y[i], y_inner[i]], [z[i], z_inner[i]], 
                color='#F5276C', alpha=0.25, linewidth=0.6)

ax.set_xlabel('X', fontsize=11, color='white')
ax.set_ylabel('Y', fontsize=11, color='white')
ax.set_zlabel('Z', fontsize=11, color='white')
ax.set_title('Electromagnetic Field Lines', fontsize=14, color='white', fontweight='bold', pad=15)

ax.tick_params(colors='#888888', labelsize=9)
ax.xaxis.pane.fill = False
ax.yaxis.pane.fill = False
ax.zaxis.pane.fill = False
ax.xaxis.pane.set_edgecolor('#333333')
ax.yaxis.pane.set_edgecolor('#333333')
ax.zaxis.pane.set_edgecolor('#333333')
ax.grid(True, alpha=0.3, color='#555555')

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

3D Charts

Did this help you?

Support PyLucid to keep it free & growing

Support