3D Quiver

Ocean Current Layers (Ekman Spiral)

Ocean current vectors showing the Ekman spiral effect where current direction rotates with depth.

Output
Ocean Current Layers (Ekman Spiral)
Python
import matplotlib.pyplot as plt
import numpy as np

# Ocean current at different depths
n = 6
x = np.linspace(-2, 2, n)
y = np.linspace(-2, 2, n)
z = np.linspace(-2, 0, 4)  # Negative = depth
X, Y, Z = np.meshgrid(x, y, z)

# Current varies with depth (Ekman spiral)
angle = -Z * 0.5  # Rotation with depth
speed = np.exp(Z * 0.5)  # Decay with depth
U = speed * np.cos(angle)
V = speed * np.sin(angle)
W = np.zeros_like(X)

fig = plt.figure(figsize=(10, 8), facecolor='#ffffff')
ax = fig.add_subplot(111, projection='3d', facecolor='#ffffff')

ax.quiver(X, Y, Z, U, V, W, length=0.35, normalize=True,
          color='#3b82f6', 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, 0.5)

ax.set_xlabel('East', color='#1f2937', fontsize=10)
ax.set_ylabel('North', color='#1f2937', fontsize=10)
ax.set_zlabel('Depth (km)', color='#1f2937', fontsize=10)
ax.set_title('Ocean Current Layers (Ekman Spiral)', color='#1f2937', fontsize=14, 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=25, azim=40)
plt.tight_layout()
plt.show()
Library

Matplotlib

Category

3D Charts

Did this help you?

Support PyLucid to keep it free & growing

Support