3D Scatter
Ocean Microplastics Distribution
3D distribution of microplastic particles in ocean water column by size and density.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
np.random.seed(111)
# Microplastic particles in ocean water column
n_particles = 250
# Horizontal spread (ocean area)
x = np.random.uniform(-10, 10, n_particles)
y = np.random.uniform(-10, 10, n_particles)
# Depth distribution (more near surface)
z = -np.random.exponential(20, n_particles)
# Particle size
size = np.random.exponential(1, n_particles) + 0.1
particle_sizes = size * 50
# Density affects sinking
density = np.random.uniform(0.9, 1.4, n_particles)
fig = plt.figure(figsize=(10, 8), facecolor='#ffffff')
ax = fig.add_subplot(111, projection='3d', facecolor='#ffffff')
scatter = ax.scatter(x, y, z, c=density, cmap='YlOrRd', s=particle_sizes,
alpha=0.6, edgecolors='#92400e', linewidths=0.3)
cbar = plt.colorbar(scatter, ax=ax, shrink=0.6, pad=0.1)
cbar.set_label('Density (g/cm³)', color='#1f2937', fontsize=10)
cbar.ax.tick_params(colors='#6b7280')
ax.set_xlabel('X (km)', color='#1f2937', fontsize=10)
ax.set_ylabel('Y (km)', color='#1f2937', fontsize=10)
ax.set_zlabel('Depth (m)', color='#1f2937', fontsize=10)
ax.set_title('Ocean Microplastics Distribution', 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=45)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
3D Charts
☕