3D Scatter
Drone Swarm Formation
Multi-drone swarm positions in 3D formation with battery status indicators.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
np.random.seed(111)
# Drone swarm formation
n_drones = 80
# Formation pattern (sphere-like with layers)
theta = np.random.uniform(0, 2*np.pi, n_drones)
phi = np.random.uniform(0, np.pi, n_drones)
r = np.random.choice([5, 10, 15], n_drones)
x = r * np.sin(phi) * np.cos(theta)
y = r * np.sin(phi) * np.sin(theta)
z = r * np.cos(phi) + 20 # Base altitude
# Status coloring
battery = np.random.uniform(20, 100, n_drones)
colors = []
for b in battery:
if b > 60:
colors.append('#6CF527') # Good
elif b > 30:
colors.append('#F5B027') # Medium
else:
colors.append('#F5276C') # Low
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=80, alpha=0.8, edgecolors='#374151', linewidths=0.5)
ax.set_xlabel('X (m)', color='#1f2937', fontsize=10)
ax.set_ylabel('Y (m)', color='#1f2937', fontsize=10)
ax.set_zlabel('Altitude (m)', color='#1f2937', fontsize=10)
ax.set_title('Drone Swarm Formation', 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
☕