File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1758,7 +1758,7 @@ def figaspect(arg):
17581758 Thanks to Fernando Perez for this function
17591759 """
17601760
1761- isarray = hasattr (arg , 'shape' )
1761+ isarray = hasattr (arg , 'shape' ) and not np . isscalar ( arg )
17621762
17631763 # min/max sizes to respect when autoscaling. If John likes the idea, they
17641764 # could become rc parameters, for now they're hardwired.
Original file line number Diff line number Diff line change 88from matplotlib .testing .decorators import image_comparison , cleanup
99from matplotlib .axes import Axes
1010import matplotlib .pyplot as plt
11+ import numpy as np
1112
1213
1314@cleanup
@@ -191,6 +192,17 @@ def test_axes_remove():
191192 assert_equal (len (fig .axes ), 3 )
192193
193194
195+ def test_figaspect ():
196+ w , h = plt .figaspect (np .float64 (2 ) / np .float64 (1 ))
197+ assert h / w == 2
198+ w , h = plt .figaspect (2 )
199+ assert h / w == 2
200+ w , h = plt .figaspect (np .zeros ((1 , 2 )))
201+ assert h / w == 0.5
202+ w , h = plt .figaspect (np .zeros ((2 , 2 )))
203+ assert h / w == 1
204+
205+
194206if __name__ == "__main__" :
195207 import nose
196208 nose .runmodule (argv = ['-s' , '--with-doctest' ], exit = False )
You can’t perform that action at this time.
0 commit comments