Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7255a1a

Browse files
committed
axes3d panning
1 parent 214ba58 commit 7255a1a

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,11 +1237,25 @@ def _on_move(self, event):
12371237
self.stale = True
12381238
self.figure.canvas.draw_idle()
12391239

1240-
# elif self.button_pressed == 2:
1240+
elif self.button_pressed == 2:
12411241
# pan view
1242+
# get the x and y pixel coords
1243+
if dx == 0 and dy == 0:
1244+
return
1245+
minx, maxx, miny, maxy, minz, maxz = self.get_w_lims()
1246+
dx = 1-((w - dx)/w)
1247+
dy = 1-((h - dy)/h)
1248+
elev, azim = np.deg2rad(self.elev), np.deg2rad(self.azim)
12421249
# project xv, yv, zv -> xw, yw, zw
1250+
dxx = (maxx-minx) * ( dy * np.sin(elev) * np.cos(azim) + dx * np.sin(azim) )
1251+
dyy = (maxy-miny) * ( - dx * np.cos(azim) + dy * np.sin(elev) * np.sin(azim) )
1252+
dzz = (maxz-minz) * ( - dy * np.cos(elev) )
12431253
# pan
1244-
# pass
1254+
self.set_xlim3d(minx + dxx, maxx + dxx)
1255+
self.set_ylim3d(miny + dyy, maxy + dyy)
1256+
self.set_zlim3d(minz + dzz, maxz + dzz)
1257+
self.get_proj()
1258+
self.figure.canvas.draw_idle()
12451259

12461260
# Zoom
12471261
elif self.button_pressed in self._zoom_btn:

0 commit comments

Comments
 (0)