3D Scatter
Autonomous Vehicle Perception
Self-driving car sensor fusion showing detected objects classified by type.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
np.random.seed(468)
# Object detection from sensors
n_objects = 180
# Relative position to vehicle (vehicle at origin)
x = np.random.uniform(-30, 30, n_objects) # lateral
y = np.random.uniform(0, 100, n_objects) # forward
z = np.random.uniform(-2, 5, n_objects) # height
# Object classification
obj_type = np.random.choice(['Vehicle', 'Pedestrian', 'Cyclist', 'Static'], n_objects, p=[0.4, 0.25, 0.15, 0.2])
type_colors = {
'Vehicle': '#F5276C',
'Pedestrian': '#27D3F5',
'Cyclist': '#6CF527',
'Static': '#94a3b8'
}
type_sizes = {'Vehicle': 80, 'Pedestrian': 50, 'Cyclist': 60, 'Static': 30}
colors = [type_colors[t] for t in obj_type]
sizes = [type_sizes[t] for t in obj_type]
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.7, edgecolors='#374151', linewidths=0.3)
# Mark ego vehicle
ax.scatter([0], [0], [0], c='#4927F5', s=200, marker='^', label='Ego Vehicle')
ax.set_xlabel('Lateral (m)', color='#1f2937', fontsize=10)
ax.set_ylabel('Forward (m)', color='#1f2937', fontsize=10)
ax.set_zlabel('Height (m)', color='#1f2937', fontsize=10)
ax.set_title('Autonomous Vehicle Perception', 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=30, azim=45)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
3D Charts
☕