@@ -72,6 +72,31 @@ def test_axis_positions():
7272 ax .set (xlabel = 'x' , ylabel = 'y' , zlabel = 'z' , title = title )
7373
7474
75+ @mpl3d_image_comparison (['axis_positions_inverted.png' ], remove_text = False ,
76+ style = 'mpl20' )
77+ def test_axis_positions_inverted ():
78+ # Regression test for https://github.com/matplotlib/matplotlib/issues/31989
79+ # Check the visual placement of axes, ticks and labels for
80+ # every combination of inverted x, y and z axes.
81+ combinations = list (itertools .product ([False , True ], repeat = 3 ))
82+ fig , axs = plt .subplots (2 , 4 , figsize = (10 , 6 ),
83+ subplot_kw = {'projection' : '3d' })
84+ for ax , (invert_x , invert_y , invert_z ) in zip (axs .flatten (), combinations ):
85+ # Plot an asymmetric line so that inverting an axis visibly mirrors the data,
86+ # ensuring the projection is exercised for every inversion combination
87+ ax .plot ([0 , 1 , 1 ], [0 , 0 , 1 ], [0 , 1 , 1 ])
88+ if invert_x :
89+ ax .invert_xaxis ()
90+ if invert_y :
91+ ax .invert_yaxis ()
92+ if invert_z :
93+ ax .invert_zaxis ()
94+ title = (f'{ "-" if invert_x else "" } x, '
95+ f'{ "-" if invert_y else "" } y, '
96+ f'{ "-" if invert_z else "" } z' )
97+ ax .set (xlabel = 'x' , ylabel = 'y' , zlabel = 'z' , title = title )
98+
99+
75100@mpl3d_image_comparison (['aspects.png' ], remove_text = False , style = 'mpl20' )
76101def test_aspects ():
77102 aspects = ('auto' , 'equal' , 'equalxy' , 'equalyz' , 'equalxz' , 'equal' )
0 commit comments