8000 ENH: Set the default plotbox aspect to match how renders looked previ… · matplotlib/matplotlib@a7a8051 · GitHub
[go: up one dir, main page]

Skip to content
65EC

Commit a7a8051

Browse files
committed
ENH: Set the default plotbox aspect to match how renders looked previously
This sets it to have a 4:3 aspect ratio, which matches what would result from a typical figure layout
1 parent 1d4a513 commit a7a8051

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+19
-4
lines changed

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,9 @@ def get_proj(self):
10291029
point.
10301030
10311031
"""
1032+
# chosen for similarity with the initial view before gh-8896
1033+
pb_aspect = np.array([4, 4, 3]) / 3.5
1034+
10321035
relev, razim = np.pi * self.elev/180, np.pi * self.azim/180
10331036

10341037
xmin, xmax = self.get_xlim3d()
@@ -1038,10 +1041,10 @@ def get_proj(self):
10381041
# transform to uniform world coordinates 0-1.0,0-1.0,0-1.0
10391042
worldM = proj3d.world_transformation(xmin, xmax,
10401043
ymin, ymax,
1041-
zmin, zmax)
1044+
zmin, zmax, pb_aspect=pb_aspect)
10421045

10431046
# look into the middle of the new coordinates
1044-
R = np.array([0.5, 0.5, 0.5])
1047+
R = pb_aspect / 2
10451048

10461049
xp = R[0] + np.cos(razim) * np.cos(relev) * self.dist
10471050
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
@@ -86,8 +86,20 @@ def mod(v):
8686

8787
def world_transformation(xmin, xmax,
8888
ymin, ymax,
89-
zmin, zmax):
90-
dx, dy, dz = (xmax-xmin), (ymax-ymin), (zmax-zmin)
89+
zmin, zmax, pb_aspect=None):
90+
"""
91+
produce a matrix that scales homogenous coords in the specified ranges
92+
to [0, 1], or [0, pb_aspect[i]] if the plotbox aspect ratio is specified
93+
"""
94+
dx = xmax - xmin
95+
dy = ymax - ymin
96+
dz = zmax - zmin
97+
if pb_aspect is not None:
98+
ax, ay, az = pb_aspect
99+
dx /= ax
100+
dy /= ay
101+
dz /= az
102+
91103
return np.array([[1/dx, 0, 0, -xmin/dx],
92104
[0, 1/dy, 0, -ymin/dy],
93105
[0, 0, 1/dz, -zmin/dz],
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)
0