Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1eb74b6

Browse files
Comments and docstrings
1 parent47f7000 commit1eb74b6

File tree

1 file changed

+33
-32
lines changed

1 file changed

+33
-32
lines changed

‎lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 33 additions & 32 deletions
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
ifself._focal_length==np.inf:
@@ -1110,34 +1110,34 @@ def drag_pan(self, button, key, x, y):
11101110
# Calling start_pan() to set the x/y of this event as the starting
11111111
# move location for the next event
11121112
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
11151115
ifkey=='x':
1116-
dy=0
1116+
dv=0
11171117
elifkey=='y':
1118-
dx=0
1119-
ifdx==0anddy==0:
1118+
du=0
1119+
ifdu==0anddv==0:
11201120
return
11211121

11221122
# Transform the pan from the view axes to the data axees
11231123
R=np.array([self._view_u,self._view_v,self._view_n])
11241124
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])
11261126

11271127
# Calculate pan distance
11281128
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]
11321132

11331133
# 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)
11371137

11381138
def_calc_view_axes(self,eye):
11391139
"""
1140-
Get the unit viewing axes in data coordinates.
1140+
Get the unitvectors for theviewing 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,32 +1186,33 @@ 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
ifdirection=='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_n)
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-
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)
12151216

12161217
# Scale the data range
12171218
minx,maxx,miny,maxy,minz,maxz=self.get_w_lims()
@@ -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 plotting3D data, the direction to use as z ('x', 'y' or 'z').
1380+
When plotting2D 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)

[8]ページ先頭

©2009-2025 Movatter.jp