File tree Expand file tree Collapse file tree 4 files changed +29
-3
lines changed Expand file tree Collapse file tree 4 files changed +29
-3
lines changed Original file line number Diff line number Diff line change
1
+ ``Axes3D `` now preserves right angles when rotating
2
+ ---------------------------------------------------
3
+
4
+ :class: `~mpl_toolkits.mplot3d.Axes3D ` no longer stretches the plot in the x
5
+ axis after projecting.
Original file line number Diff line number Diff line change @@ -1467,9 +1467,9 @@ def apply_aspect(self, position=None):
1467
1467
"""
1468
1468
Adjust the Axes for a specified data aspect ratio.
1469
1469
1470
- Depending on `.get_adjustable` this will modify either the Axes box
1471
- (position) or the view limits. In the former case, `.get_anchor`
1472
- will affect the position.
1470
+ Depending on `.get_adjustable` this will modify either the
1471
+ Axes box (position) or the view limits. In the former case,
1472
+ `~matplotlib.axes.Axes.get_anchor` will affect the position.
1473
1473
1474
1474
Notes
1475
1475
-----
Original file line number Diff line number Diff line change @@ -265,6 +265,20 @@ def tunit_edges(self, vals=None, M=None):
265
265
(tc [7 ], tc [4 ])]
266
266
return edges
267
267
268
+ def apply_aspect (self , position = None ):
269
+ if position is None :
270
+ position = self .get_position (original = True )
271
+
272
+ # in the superclass, we would go through and actually deal with axis
273
+ # scales and box/datalim. Those are all irrelevant - all we need to do
274
+ # is make sure our coordinate system is square.
275
+ figW , figH = self .get_figure ().get_size_inches ()
276
+ fig_aspect = figH / figW
277
+ box_aspect = 1
278
+ pb = position .frozen ()
279
+ pb1 = pb .shrunk_to_aspect (box_aspect , pb , fig_aspect )
280
+ self .set_position (pb1 .anchored (self .get_anchor (), pb ), 'active' )
281
+
268
282
@artist .allow_rasterization
269
283
8000
def draw (self , renderer ):
270
284
# draw the background patch
Original file line number Diff line number Diff line change @@ -478,6 +478,13 @@ def test_axes3d_cla():
478
478
ax .cla () # make sure the axis displayed is 3D (not 2D)
479
479
480
480
481
+ @image_comparison (['axes3d_rotated.png' ])
482
+ def test_axes3d_rotated ():
483
+ fig = plt .figure ()
484
+ ax = fig .add_subplot (1 , 1 , 1 , projection = '3d' )
485
+ ax .view_init (90 , 45 ) # look down, rotated. Should be square
486
+
487
+
481
488
def test_plotsurface_1d_raises ():
482
489
x = np .linspace (0.5 , 10 , num = 100 )
483
490
y = np .linspace (0.5 , 10 , num = 100 )
<
28FB
footer class="footer pt-8 pb-6 f6 color-fg-muted p-responsive" role="contentinfo" >
Footer
You can’t perform that action at this time.
0 commit comments