24
24
image_comparison , remove_text = True , style = 'default' )
25
25
26
26
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
+
27
36
@check_figures_equal (extensions = ["png" ])
28
37
def test_invisible_axes (fig_test , fig_ref ):
29
38
ax = fig_test .subplots (subplot_kw = dict (projection = '3d' ))
@@ -32,20 +41,19 @@ def test_invisible_axes(fig_test, fig_ref):
32
41
33
42
@mpl3d_image_comparison (['aspects.png' ], remove_text = False )
34
43
def 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' })
37
46
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 ])
47
54
ax .set_box_aspect ((3 , 4 , 5 ))
48
55
ax .set_aspect (aspects [i ], adjustable = 'datalim' )
56
+ axs [1 ][2 ].set_title ('equal (cube)' )
49
57
50
58
51
59
@mpl3d_image_comparison (['aspects_adjust_box.png' ], remove_text = False )
@@ -54,15 +62,9 @@ def test_aspects_adjust_box():
54
62
fig , axs = plt .subplots (1 , len (aspects ), subplot_kw = {'projection' : '3d' },
55
63
figsize = (11 , 3 ))
56
64
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 ))
65
65
for i , ax in enumerate (axs ):
66
+ plot_cuboid (ax , scale = [4 , 3 , 5 ])
67
+ ax .set_title (aspects [i ])
66
68
ax .set_aspect (aspects [i ], adjustable = 'box' )
67
69
68
70
0 commit comments