@@ -872,9 +872,9 @@ def get_proj(self):
872
872
873
873
# Calculate the viewing axes for the eye position
874
874
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
878
878
879
879
# Generate the view and projection transformation matrices
880
880
if self ._focal_length == np .inf :
@@ -1110,34 +1110,34 @@ def drag_pan(self, button, key, x, y):
1110
1110
# Calling start_pan() to set the x/y of this event as the starting
1111
1111
# move location for the next event
1112
1112
self .start_pan (x , y , button )
1113
- dx , dy = xdata - xdata_start , ydata - ydata_start
1114
- dz = 0
1113
+ du , dv = xdata - xdata_start , ydata - ydata_start
1114
+ dn = 0
1115
1115
if key == 'x' :
1116
- dy = 0
1116
+ dv = 0
1117
1117
elif key == 'y' :
1118
- dx = 0
1119
- if dx == 0 and dy == 0 :
1118
+ du = 0
1119
+ if du == 0 and dv == 0 :
1120
1120
return
1121
1121
1122
1122
# Transform the pan from the view axes to the data axees
1123
1123
R = np .array ([self ._view_u , self ._view_v , self ._view_n ])
1124
1124
R = - R / self ._box_aspect * self ._dist
1125
- dxyz_projected = R .T @ np .array ([dx , dy , dz ])
1125
+ duvn_projected = R .T @ np .array ([du , dv , dn ])
1126
1126
1127
1127
# Calculate pan distance
1128
1128
minx , maxx , miny , maxy , minz , maxz = self .get_w_lims ()
1129
- dxx = (maxx - minx ) * dxyz_projected [0 ]
1130
- dyy = (maxy - miny ) * dxyz_projected [1 ]
1131
- dzz = (maxz - minz ) * dxyz_projected [2 ]
1129
+ dx = (maxx - minx ) * duvn_projected [0 ]
1130
+ dy = (maxy - miny ) * duvn_projected [1 ]
1131
+ dz = (maxz - minz ) * duvn_projected [2 ]
1132
1132
1133
1133
# Set the new axis limits
1134
- self .set_xlim3d (minx + dxx , maxx + dxx )
1135
- self .set_ylim3d (miny + dyy , maxy + dyy )
1136
- self .set_zlim3d (minz + dzz , maxz + dzz )
1134
+ self .set_xlim3d (minx + dx , maxx + dx )
1135
+ self .set_ylim3d (miny + dy , maxy + dy )
1136
+ self .set_zlim3d (minz + dz , maxz + dz )
1137
1137
1138
1138
def _calc_view_axes (self , eye ):
1139
1139
"""
1140
- Get the unit viewing axes in data coordinates.
1140
+ Get the unit vectors for the viewing axes in data coordinates.
1141
1141
`u` is towards the right of the screen
1142
1142
`v` is towards the top of the screen
1143
1143
`n` is out of the screen
@@ -1186,32 +1186,33 @@ def _set_view_from_bbox(self, bbox, direction='in',
1186
1186
# Calculate zoom level
1187
1187
dx = abs (start_x - stop_x )
1188
1188
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
1192
1192
1193
1193
# 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 )
1196
1196
1197
1197
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
1200
1200
1201
- self ._zoom_data_limits (scale_x , scale_y , scale_z )
1201
+ self ._zoom_data_limits (scale_u , scale_v , scale_n )
1202
1202
1203
- def _zoom_data_limits (self , scale_x , scale_y , scale_z ):
1203
+ def _zoom_data_limits (self , scale_u , scale_v , scale_n ):
1204
1204
"""
1205
1205
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.
1210
1211
"""
1211
1212
# Convert from the scale factors in the view frame to the data frame
1212
1213
R = np .array ([self ._view_u , self ._view_v , self ._view_n ])
1213
- S = np .array ([scale_x , scale_y , scale_z ] )
1214
- scale = np .linalg .norm (R .T @( np . eye ( 3 ) * S ) , axis = 1 )
1214
+ S = np .array ([scale_u , scale_v , scale_n ]) * np . eye ( 3 )
1215
+ scale = np .linalg .norm (R .T @ S , axis = 1 )
1215
1216
1216
1217
# Scale the data range
1217
1218
minx , maxx , miny , maxy , minz , maxz = self .get_w_lims ()
@@ -1376,7 +1377,7 @@ def plot(self, xs, ys, *args, zdir='z', **kwargs):
1376
1377
z coordinates of vertices; either one for all points or one for
1377
1378
each point.
1378
1379
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').
1380
1381
**kwargs
1381
1382
Other arguments are forwarded to `matplotlib.axes.Axes.plot`.
1382
1383
"""
0 commit comments