Skip to content

Commit 16a5e9c

Browse files
3d plot view angle documentation
1 parent 9b1fcf6 commit 16a5e9c

File tree

4 files changed

+44
-2
lines changed

4 files changed

+44
-2
lines changed
144 KB
Loading
78.2 KB
Loading

doc/api/toolkits/mplot3d.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ more information.
2020

2121
The interactive backends also provide the ability to rotate and zoom the 3D
2222
scene. One can rotate the 3D scene by simply clicking-and-dragging the scene.
23-
Zooming is done by right-clicking the scene and dragging the mouse up and down
24-
(unlike 2D plots, the toolbar zoom button is not used).
23+
Panning is done by clicking the middle mouse button, and zooming is done by
24+
right-clicking the scene and dragging the mouse up and down. Unlike 2D plots,
25+
the toolbar pan and zoom buttons are not used.
2526

2627
.. toctree::
2728
:maxdepth: 2
2829

2930
mplot3d/faq.rst
31+
mplot3d/view_angles.rst
3032

3133
.. note::
3234
`.pyplot` cannot be used to add content to 3D plots, because its function
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
.. _toolkit_mplot3d-view-angles:
2+
3+
*******************
4+
mplot3d View Angles
5+
*******************
6+
7+
How to define the view angle
8+
============================
9+
10+
The position of the viewport "camera" in a 3D plot is defined by three angles:
11+
elevation, azimuth, and roll. From the resulting position, it always points
12+
towards the center of the plot box volume. The angle direction convention is
13+
shared with
14+
`PyVista <https://docs.pyvista.org/api/core/camera.html>`_ and
15+
`MATLAB <https://www.mathworks.com/help/matlab/ref/view.html>`_
16+
(though MATLAB lacks a roll angle).
17+
18+
.. image:: /_static/mplot3d_view_angles.png
19+
:align: center
20+
:scale: 50
21+
22+
Rotating the plot using the mouse will control only the azimuth and elevation,
23+
but all three angles can be set programmatically::
24+
25+
import matplotlib.pyplot as plt
26+
ax = plt.figure().add_subplot(projection='3d')
27+
ax.view_init(elev=30, azim=45, roll=15)
28+
29+
30+
Primary view planes
31+
===================
32+
33+
To look directly at the primary view planes, the required elevation, azimuth,
34+
and roll angles are shown in the diagram of an "unfolded" plot below. You could
35+
print out this image and fold it into a box where each plane forms a side of
36+
the box. These are further documented in the `.mplot3d.axes3d.Axes3D.view_init`
37+
API.
38+
39+
.. image:: /_static/mplot3d_primary_view_planes.png
40+
:align: center

0 commit comments

Comments
 (0)