3D Quiver
Magnetic Dipole Field
A 3D vector field showing magnetic dipole field lines radiating from the origin.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
# Magnetic dipole field
n = 5
x = np.linspace(-2, 2, n)
y = np.linspace(-2, 2, n)
z = np.linspace(-2, 2, n)
X, Y, Z = np.meshgrid(x, y, z)
# Dipole field equations (simplified)
r = np.sqrt(X**2 + Y**2 + Z**2) + 0.5
U = 3 * X * Z / r**5
V = 3 * Y * Z / r**5
W = (3 * Z**2 - r**2) / r**5
# Normalize for visualization
mag = np.sqrt(U**2 + V**2 + W**2)
U, V, W = U/mag, V/mag, W/mag
fig = plt.figure(figsize=(10, 8), facecolor='#0a0a0f')
ax = fig.add_subplot(111, projection='3d', facecolor='#0a0a0f')
ax.quiver(X, Y, Z, U, V, W, length=0.4, normalize=True,
color='#06b6d4', alpha=0.8, arrow_length_ratio=0.3)
ax.set_xlim(-2.5, 2.5)
ax.set_ylim(-2.5, 2.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('Magnetic Dipole Field', 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.view_init(elev=20, azim=45)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
3D Charts
☕