@@ -27,27 +27,22 @@ def test_invisible_axes(fig_test, fig_ref):
27
27
ax .set_visible (False )
28
28
29
29
30
- @mpl3d_image_comparison (['aspect_equal.png' ], remove_text = False )
31
- def test_aspect_equal ():
32
- fig = plt .figure ()
33
- ax = fig .add_subplot (projection = '3d' )
34
-
35
- points = np .array ([[0 , 0 , 0 ], [1 , 0 , 0 ], [0 , 1 , 0 ], [1 , 1 , 0 ],
36
- [0 , 0 , 3 ], [1 , 0 , 3 ], [0 , 1 , 3 ], [1 , 1 , 3 ]])
37
-
38
- x = np .asarray ([coord [0 ] for coord in points ])
39
- y = np .asarray ([coord [1 ] for coord in points ])
40
- z = np .asarray ([coord [2 ] for coord in points ])
41
-
42
- def plot_edge (i , j ):
43
- ax .plot ([x [i ], x [j ]], [y [i ], y [j ]], [z [i ], z [j ]], c = 'r' )
44
-
45
- # hexaedron creation
46
- plot_edge (0 , 1 ), plot_edge (1 , 3 ), plot_edge (3 , 2 ), plot_edge (2 , 0 )
47
- plot_edge (4 , 5 ), plot_edge (5 , 7 ), plot_edge (7 , 6 ), plot_edge (6 , 4 )
48
- plot_edge (0 , 4 ), plot_edge (1 , 5 ), plot_edge (3 , 7 ), plot_edge (2 , 6 )
49
-
50
- ax .set_aspect ('equal' )
30
+ @mpl3d_image_comparison (['aspects.png' ], remove_text = False )
31
+ def test_aspects ():
32
+ aspects = ('auto' , 'equal' , 'equalxy' , 'equalyz' , 'equalxz' )
33
+ fig , axs = plt .subplots (1 , len (aspects ), subplot_kw = {'projection' : '3d' })
34
+
35
+ # Draw rectangular cuboid with side lengths [1, 1, 2]
36
+ r = [0 , 1 ]
37
+ scale = np .array ([1 , 1 , 2 ])
38
+ pts = itertools .combinations (np .array (list (itertools .product (r , r , r ))), 2 )
39
+ for start , end in pts :
40
+ if np .sum (np .abs (start - end )) == r [1 ] - r [0 ]:
41
+ for ax in axs :
42
+ ax .plot3D (* zip (start * scale , end * scale ))
43
+ for i , ax in enumerate (axs ):
44
+ ax .set_box_aspect ((3 , 4 , 5 ))
45
+ ax .set_aspect (aspects [i ])
51
46
52
47
53
48
@mpl3d_image_comparison (['bar3d.png' ])
0 commit comments