2424 image_comparison , remove_text = True , style = 'default' )
2525
2626
27+ def plot_cuboid (ax , scale ):
28+ # plot a rectangular cuboid with side lengths given by scale (x, y, z)
29+ r = [0 , 1 ]
30+ pts = itertools .combinations (np .array (list (itertools .product (r , r , r ))), 2 )
31+ for start , end in pts :
32+ if np .sum (np .abs (start - end )) == r [1 ] - r [0 ]:
33+ ax .plot3D (* zip (start * np .array (scale ), end * np .array (scale )))
34+
35+
2736@check_figures_equal (extensions = ["png" ])
2837def test_invisible_axes (fig_test , fig_ref ):
2938 ax = fig_test .subplots (subplot_kw = dict (projection = '3d' ))
@@ -32,20 +41,19 @@ def test_invisible_axes(fig_test, fig_ref):
3241
3342@mpl3d_image_comparison (['aspects.png' ], remove_text = False )
3443def test_aspects ():
35- aspects = ('auto' , 'equal' , 'equalxy' , 'equalyz' , 'equalxz' )
36- fig , axs = plt .subplots (1 , len ( aspects ) , subplot_kw = {'projection' : '3d' })
44+ aspects = ('auto' , 'equal' , 'equalxy' , 'equalyz' , 'equalxz' , 'equal' )
45+ _ , axs = plt .subplots (2 , 3 , subplot_kw = {'projection' : '3d' })
3746
38- # Draw rectangular cuboid with side lengths [1, 1, 5]
39- r = [0 , 1 ]
40- scale = np .array ([1 , 1 , 5 ])
41- pts = itertools .combinations (np .array (list (itertools .product (r , r , r ))), 2 )
42- for start , end in pts :
43- if np .sum (np .abs (start - end )) == r [1 ] - r [0 ]:
44- for ax in axs :
45- ax .plot3D (* zip (start * scale , end * scale ))
46- for i , ax in enumerate (axs ):
47+ for ax in axs .flatten ()[0 :- 1 ]:
48+ plot_cuboid (ax , scale = [1 , 1 , 5 ])
49+ # plot a cube as well to cover github #25443
50+ plot_cuboid (axs [1 ][2 ], scale = [1 , 1 , 1 ])
51+
52+ for i , ax in enumerate (axs .flatten ()):
53+ ax .set_title (aspects [i ])
4754 ax .set_box_aspect ((3 , 4 , 5 ))
4855 ax .set_aspect (aspects [i ], adjustable = 'datalim' )
56+ axs [1 ][2 ].set_title ('equal (cube)' )
4957
5058
5159@mpl3d_image_comparison (['aspects_adjust_box.png' ], remove_text = False )
@@ -54,15 +62,9 @@ def test_aspects_adjust_box():
5462 fig , axs = plt .subplots (1 , len (aspects ), subplot_kw = {'projection' : '3d' },
5563 figsize = (11 , 3 ))
5664
57- # Draw rectangular cuboid with side lengths [4, 3, 5]
58- r = [0 , 1 ]
59- scale = np .array ([4 , 3 , 5 ])
60- pts = itertools .combinations (np .array (list (itertools .product (r , r , r ))), 2 )
61- for start , end in pts :
62- if np .sum (np .abs (start - end )) == r [1 ] - r [0 ]:
63- for ax in axs :
64- ax .plot3D (* zip (start * scale , end * scale ))
6565 for i , ax in enumerate (axs ):
66+ plot_cuboid (ax , scale = [4 , 3 , 5 ])
67+ ax .set_title (aspects [i ])
6668 ax .set_aspect (aspects [i ], adjustable = 'box' )
6769
6870
0 commit comments