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

Skip to content

Commit bbeb534

Browse files
committed
BUG: Fix the aspect ratio of 3d plots
Fixes gh-8894, by always using a "position" that maintains a uniform coordinate system. Test added - when viewed from above, the plot should be square not rhombic.
1 parent 9fab0bd commit bbeb534

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

+20
-0
lines changed

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,20 @@ def tunit_edges(self, vals=None, M=None):
266266
(tc[7], tc[4])]
267267
return edges
268268

269+
def apply_aspect(self, position=None):
270+
if position is None:
271+
position = self.get_position(original=True)
272+
273+
# in the superclass, we would go through and actually deal with axis
274+
# scales and box/datalim. Those are all irrelevant - all we need to do
275+
# is make sure our coordinate system is square.
276+
figW, figH = self.get_figure().get_size_inches()
277+
fig_aspect = figH / figW
278+
box_aspect = 1
279+
pb = position.frozen()
280+
pb1 = pb.shrunk_to_aspect(box_aspect, pb, fig_aspect)
281+
self.set_position(pb1.anchored(self.get_anchor(), pb), 'active')
282+
269283
@artist.allow_rasterization
270284
def draw(self, renderer):
271285
# draw the background patch
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)