3D Scatter
Particle Accelerator Beam Profile
High-energy physics beam diagnostics showing particle distribution and energy spread.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
np.random.seed(1234)
# Particle beam profile
n_particles = 300
# Gaussian beam profile
x = np.random.normal(0, 0.5, n_particles)
y = np.random.normal(0, 0.5, n_particles)
z = np.random.uniform(0, 10, n_particles) # Along beam axis
# Energy spread
energy = 100 + np.random.normal(0, 2, n_particles) # GeV
energy_norm = (energy - energy.min()) / (energy.max() - energy.min())
# Color by energy
colors = []
for e in energy_norm:
if e < 0.33:
colors.append('#27D3F5') # Low
elif e < 0.66:
colors.append('#6CF527') # Medium
else:
colors.append('#F5276C') # High
sizes = energy_norm * 50 + 20
fig = plt.figure(figsize=(10, 8), facecolor='#ffffff')
ax = fig.add_subplot(111, projection='3d', facecolor='#ffffff')
ax.scatter(x, y, z, c=colors, s=sizes, alpha=0.6, edgecolors='white', linewidths=0.2)
ax.set_xlabel('X (mm)', color='#1f2937', fontsize=10)
ax.set_ylabel('Y (mm)', color='#1f2937', fontsize=10)
ax.set_zlabel('Z - Beam Axis (m)', color='#1f2937', fontsize=10)
ax.set_title('Particle Accelerator Beam Profile', 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=15, azim=45)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
3D Charts
More 3D Scatter examples
☕