3D Scatter
LiDAR Point Cloud - Urban Scene
LiDAR point cloud visualization of an urban scene with terrain and buildings.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
np.random.seed(456)
# Simulate LiDAR scan of terrain with buildings
n_points = 500
# Ground plane with slight slope
x_ground = np.random.uniform(-5, 5, n_points // 2)
y_ground = np.random.uniform(-5, 5, n_points // 2)
z_ground = 0.1 * x_ground + np.random.normal(0, 0.1, n_points // 2)
# Building 1
n_build = n_points // 4
x_b1 = np.random.uniform(1, 2.5, n_build)
y_b1 = np.random.uniform(-2, 0, n_build)
z_b1 = np.random.uniform(0, 3, n_build)
# Building 2
x_b2 = np.random.uniform(-3, -1.5, n_build)
y_b2 = np.random.uniform(1, 3, n_build)
z_b2 = np.random.uniform(0, 2, n_build)
x = np.concatenate([x_ground, x_b1, x_b2])
y = np.concatenate([y_ground, y_b1, y_b2])
z = np.concatenate([z_ground, z_b1, z_b2])
fig = plt.figure(figsize=(10, 8), facecolor='#ffffff')
ax = fig.add_subplot(111, projection='3d', facecolor='#ffffff')
scatter = ax.scatter(x, y, z, c=z, cmap='terrain', s=8, alpha=0.8, edgecolors='none')
cbar = plt.colorbar(scatter, ax=ax, shrink=0.6, pad=0.1)
cbar.set_label('Elevation (m)', color='#1f2937', fontsize=10)
cbar.ax.tick_params(colors='#6b7280')
ax.set_xlabel('X (m)', color='#1f2937', fontsize=10)
ax.set_ylabel('Y (m)', color='#1f2937', fontsize=10)
ax.set_zlabel('Z (m)', color='#1f2937', fontsize=10)
ax.set_title('LiDAR Point Cloud - Urban Scene', 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
☕