|
| 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). Note that a positive roll angle rotates the |
| 17 | +viewing plane clockwise, so the 3d axes will appear to rotate |
| 18 | +counter-clockwise. |
| 19 | + |
| 20 | +.. image:: /_static/mplot3d_view_angles.png |
| 21 | + :align: center |
| 22 | + :scale: 50 |
| 23 | + |
| 24 | +Rotating the plot using the mouse will control only the azimuth and elevation, |
| 25 | +but all three angles can be set programmatically:: |
| 26 | + |
| 27 | + import matplotlib.pyplot as plt |
| 28 | + ax = plt.figure().add_subplot(projection='3d') |
| 29 | + ax.view_init(elev=30, azim=45, roll=15) |
| 30 | + |
| 31 | + |
| 32 | +Primary view planes |
| 33 | +=================== |
| 34 | + |
| 35 | +To look directly at the primary view planes, the required elevation, azimuth, |
| 36 | +and roll angles are shown in the diagram of an "unfolded" plot below. You could |
| 37 | +print out this image and fold it into a box where each plane forms a side of |
| 38 | +the box. These are further documented in the `.mplot3d.axes3d.Axes3D.view_init` |
| 39 | +API. |
| 40 | + |
| 41 | +.. image:: /_static/mplot3d_primary_view_planes.png |
| 42 | + :align: center |
0 commit comments