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

Skip to content

Commit 58b9311

Browse files
committed
ENH: Set the default plotbox aspect to match how renders looked previously
1 parent 88fb88a commit 58b9311

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,8 @@ def get_proj(self):
999999
point.
10001000
10011001
"""
1002+
pb_aspect = np.array([1, 1, 0.75])
1003+
10021004
relev, razim = np.pi * self.elev/180, np.pi * self.azim/180
10031005

10041006
xmin, xmax = self.get_xlim3d()
@@ -1008,10 +1010,10 @@ def get_proj(self):
10081010
# transform to uniform world coordinates 0-1.0,0-1.0,0-1.0
10091011
worldM = proj3d.world_transformation(xmin, xmax,
10101012
ymin, ymax,
1011-
zmin, zmax)
1013+
zmin, zmax, pb_aspect=pb_aspect)
10121014

10131015
# look into the middle of the new coordinates
1014-
R = np.array([0.5, 0.5, 0.5])
1016+
R = pb_aspect / 2
10151017

10161018
xp = R[0] + np.cos(razim) * np.cos(relev) * self.dist
10171019
yp = R[1] + np.sin(razim) * np.cos(relev) * self.dist

lib/mpl_toolkits/mplot3d/proj3d.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,20 @@ def mod(v):
7474

7575
def world_transformation(xmin, xmax,
7676
ymin, ymax,
77-
zmin, zmax):
78-
dx, dy, dz = (xmax-xmin), (ymax-ymin), (zmax-zmin)
77+
zmin, zmax, pb_aspect=None):
78+
"""
79+
produce a matrix that scales homogenous coords in the specified ranges
80+
to [0, 1], or [0, pb_aspect[i]] if the plotbox aspect ratio is specified
81+
"""
82+
dx = xmax - xmin
83+
dy = ymax - ymin
84+
dz = zmax - zmin
85+
if pb_aspect is not None:
86+
ax, ay, az = pb_aspect
87+
dx /= ax
88+
dy /= ay
89+
dz /= az
90+
7991
return np.array([
8092
[1.0/dx,0,0,-xmin/dx],
8193
[0,1.0/dy,0,-ymin/dy],

0 commit comments

Comments
 (0)