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