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

Skip to content
10000

Commit 76a36bb

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 bbeb534 commit 76a36bb

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

+18
-4
lines changed

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 4 additions & 2 deletions
< 9E81 tr class="diff-line-row">
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,8 @@ def get_proj(self):
10291029
point.
10301030
10311031
"""
1032+
pb_aspect = np.array([1, 1, 0.75])
1033+
10321034
relev, razim = np.pi * self.elev/180, np.pi * self.azim/180
10331035

10341036
xmin, xmax = self.get_xlim3d()
@@ -1038,10 +1040,10 @@ def get_proj(self):
10381040
# transform to uniform world coordinates 0-1.0,0-1.0,0-1.0
10391041
worldM = proj3d.world_transformation(xmin, xmax,
10401042
ymin, ymax,
1041-
zmin, zmax)
1043+
zmin, zmax, pb_aspect=pb_aspect)
10421044

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

10461048
xp = R[0] + np.cos(razim) * np.cos(relev) * self.dist
10471049
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 F438 file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)
0