3D Scatter
Turbulent Flow Particle Tracer
Particle tracking in turbulent fluid flow showing advection through a vortex structure.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
np.random.seed(888)
# Particles in turbulent flow
n_particles = 300
n_timesteps = 5
# Initial positions
x0 = np.random.uniform(-2, 2, n_particles)
y0 = np.random.uniform(-2, 2, n_particles)
z0 = np.random.uniform(0, 4, n_particles)
# Simulate advection with vortex
all_x, all_y, all_z, all_t = [], [], [], []
for t in range(n_timesteps):
dt = t * 0.3
# Vortex motion
r = np.sqrt(x0**2 + y0**2) + 0.1
x = x0 * np.cos(dt/r) - y0 * np.sin(dt/r) + np.random.normal(0, 0.1, n_particles)
y = x0 * np.sin(dt/r) + y0 * np.cos(dt/r) + np.random.normal(0, 0.1, n_particles)
z = z0 + dt * 0.5 + np.random.normal(0, 0.1, n_particles)
all_x.extend(x)
all_y.extend(y)
all_z.extend(z)
all_t.extend([t] * n_particles)
fig = plt.figure(figsize=(10, 8), facecolor='#0a0a0f')
ax = fig.add_subplot(111, projection='3d', facecolor='#0a0a0f')
scatter = ax.scatter(all_x, all_y, all_z, c=all_t, cmap='viridis',
s=10, alpha=0.5, edgecolors='none')
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('Turbulent Flow Particle Tracer', 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=25, azim=45)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
3D Charts
☕