Skip to content

Commit 026802a

Browse files
Comments and docstrings
1 parent 47f7000 commit 026802a

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

lib/mpl_toolkits/mplot3d/axes3d.py

+20-19
Original file line numberDiff line numberDiff line change
@@ -872,9 +872,9 @@ def get_proj(self):
872872

873873
# Calculate the viewing axes for the eye position
874874
u, v, n = self._calc_view_axes(eye)
875-
self._view_u = u
876-
self._view_v = v
877-
self._view_n = n
875+
self._view_u = u # _view_u is towards the right of the screen
876+
self._view_v = v # _view_v is towards the top of the screen
877+
self._view_n = n # _view_n is out of the screen
878878

879879
# Generate the view and projection transformation matrices
880880
if self._focal_length == np.inf:
@@ -1137,7 +1137,7 @@ def drag_pan(self, button, key, x, y):
11371137

11381138
def _calc_view_axes(self, eye):
11391139
"""
1140-
Get the unit viewing axes in data coordinates.
1140+
Get the unit vectors for the viewing axes in data coordinates.
11411141
`u` is towards the right of the screen
11421142
`v` is towards the top of the screen
11431143
`n` is out of the screen
@@ -1186,31 +1186,32 @@ def _set_view_from_bbox(self, bbox, direction='in',
11861186
# Calculate zoom level
11871187
dx = abs(start_x - stop_x)
11881188
dy = abs(start_y - stop_y)
1189-
scale_x = dx / (self.bbox.max[0] - self.bbox.min[0])
1190-
scale_y = dy / (self.bbox.max[1] - self.bbox.min[1])
1191-
scale_z = 1
1189+
scale_u = dx / (self.bbox.max[0] - self.bbox.min[0])
1190+
scale_v = dy / (self.bbox.max[1] - self.bbox.min[1])
1191+
scale_n = 1
11921192

11931193
# Limit box zoom to reasonable range, protect for divide by zero below
1194-
scale_x = np.clip(scale_x, 1e-2, 1e2)
1195-
scale_y = np.clip(scale_y, 1e-2, 1e2)
1194+
scale_u = np.clip(scale_u, 1e-2, 1e2)
1195+
scale_v = np.clip(scale_v, 1e-2, 1e2)
11961196

11971197
if direction == 'out':
1198-
scale_x = 1 / scale_x
1199-
scale_y = 1 / scale_y
1198+
scale_u = 1 / scale_u
1199+
scale_v = 1 / scale_v
12001200

1201-
self._zoom_data_limits(scale_x, scale_y, scale_z)
1201+
self._zoom_data_limits(scale_u, scale_v, scale_v)
12021202

1203-
def _zoom_data_limits(self, scale_x, scale_y, scale_z):
1203+
def _zoom_data_limits(self, scale_u, scale_v, scale_n):
12041204
"""
12051205
Zoom in or out of a 3D plot.
1206-
Will scale the data limits by the scale factors, where scale_x,
1207-
scale_y, and scale_z refer to the scale factors for the viewing axes.
1208-
These will be transformed to the data axes based on the current view
1209-
angles. A scale factor > 1 zooms out and a scale factor < 1 zooms in.
1206+
Will scale the data limits by the scale factors, where scale_u,
1207+
scale_v, and scale_n refer to the scale factors for the viewing axes.
1208+
These will be transformed to the x, y, z data axes based on the current
1209+
view angles. A scale factor > 1 zooms out and a scale factor < 1 zooms
1210+
in.
12101211
"""
12111212
# Convert from the scale factors in the view frame to the data frame
12121213
R = np.array([self._view_u, self._view_v, self._view_n])
1213-
S = np.array([scale_x, scale_y, scale_z])
1214+
S = np.array([scale_u, scale_v, scale_n])
12141215
scale = np.linalg.norm(R.T@(np.eye(3)*S), axis=1)
12151216

12161217
# Scale the data range
@@ -1376,7 +1377,7 @@ def plot(self, xs, ys, *args, zdir='z', **kwargs):
13761377
z coordinates of vertices; either one for all points or one for
13771378
each point.
13781379
zdir : {'x', 'y', 'z'}, default: 'z'
1379-
When plotting 3D data, the direction to use as z ('x', 'y' or 'z').
1380+
When plotting 2D data, the direction to use as z ('x', 'y' or 'z').
13801381
**kwargs
13811382
Other arguments are forwarded to `matplotlib.axes.Axes.plot`.
13821383
"""

0 commit comments

Comments
 (0)