Viewing Angles and Projection Types
You'll learn how to control the camera perspective in 3D visualizations to reveal the most informative view of your data.
When you create a 3D plot, you're essentially positioning a virtual camera around your data. Just like a photographer choosing the best angle, you can control viewing angles through two key parameters:
- Elevation: How high above (or below) the horizontal plane your camera sits, measured in degrees. Think of it like climbing stairs to look down at your scene.
- Azimuth: The horizontal rotation angle around your plot. Imagine walking in a circle around a statue—azimuth controls which side you're viewing from.
In Matplotlib's 3D toolkit, you adjust these using the view_init() method on your 3D axes object:
ax.view_init(elev=30, azim=45)
This positions your camera 30 degrees above the horizontal plane and rotated 45 degrees around the z-axis.
Projection Types
Beyond angles, you can choose between two projection types:
-
Perspective projection (default): Objects farther away appear smaller, mimicking how human eyes see the world. This creates depth but can distort proportions.
-
Orthographic projection: All objects maintain their size regardless of distance from the camera. Better for technical accuracy and comparing measurements, though it sacrifices some depth perception.
You set the projection when creating your 3D axes:
ax = fig.add_subplot(111, projection='3d', proj_type='ortho') # orthographic
ax = fig.add_subplot(111, projection='3d', proj_type='persp') # perspective
Key Takeaway: Controlling elevation, azimuth, and projection type lets you present 3D data from the most informative angle—use perspective for realistic depth or orthographic for accurate size comparisons.