@@ -1031,6 +1031,51 @@ def test_subfigure_spanning():
10311031 np .testing .assert_allclose (sub_figs [2 ].bbox .max , [w , h / 3 ])
10321032
10331033
1034+ @mpl .style .context ('mpl20' )
1035+ def test_subfigure_ticks ():
1036+ # This tests a tick-spacing error that only seems applicable
1037+ # when the subfigures are saved to file. It is very hard to replicate
1038+ fig = plt .figure (constrained_layout = True , figsize = (10 , 3 ))
1039+ # create left/right subfigs nested in bottom subfig
1040+ (subfig_bl , subfig_br ) = fig .subfigures (1 , 2 , wspace = 0.01 ,
1041+ width_ratios = [7 , 2 ])
1042+
1043+ # put ax1-ax3 in gridspec of bottom-left subfig
1044+ gs = subfig_bl .add_gridspec (nrows = 1 , ncols = 14 )
1045+
1046+ ax1 = subfig_bl .add_subplot (gs [0 , :1 ])
1047+ ax1 .scatter (x = [- 56.46881504821776 , 24.179891162109396 ], y = [1500 , 3600 ])
1048+
1049+ ax2 = subfig_bl .add_subplot (gs [0 , 1 :3 ], sharey = ax1 )
1050+ ax2 .scatter (x = [- 126.5357270050049 , 94.68456736755368 ], y = [1500 , 3600 ])
1051+ ax3 = subfig_bl .add_subplot (gs [0 , 3 :14 ], sharey = ax1 )
1052+
1053+ fig .set_dpi (120 )
1054+ fig .draw_no_output ()
1055+ ticks120 = ax2 .get_xticks ()
1056+ fig .set_dpi (300 )
1057+ fig .draw_no_output ()
1058+ ticks300 = ax2 .get_xticks ()
1059+ np .testing .assert_allclose (ticks120 , ticks300 )
1060+
1061+
1062+ @image_comparison (['test_subfigure_scatter_size.png' ], style = 'mpl20' ,
1063+ remove_text = True )
1064+ def test_subfigure_scatter_size ():
1065+ # markers in the left- and right-most subplots should be the same
1066+ fig = plt .figure ()
1067+ gs = fig .add_gridspec (1 , 2 )
1068+ ax0 = fig .add_subplot (gs [1 ])
1069+ ax0 .scatter ([1 , 2 , 3 ], [1 , 2 , 3 ], s = 30 , marker = 's' )
1070+ ax0 .scatter ([3 , 4 , 5 ], [1 , 2 , 3 ], s = [20 , 30 , 40 ], marker = 's' )
1071+
1072+ sfig = fig .add_subfigure (gs [0 ])
1073+ axs = sfig .subplots (1 , 2 )
1074+ for ax in [ax0 , axs [0 ]]:
1075+ ax .scatter ([1 , 2 , 3 ], [1 , 2 , 3 ], s = 30 , marker = 's' , color = 'r' )
1076+ ax .scatter ([3 , 4 , 5 ], [1 , 2 , 3 ], s = [20 , 30 , 40 ], marker = 's' , color = 'g' )
1077+
1078+
10341079def test_add_subplot_kwargs ():
10351080 # fig.add_subplot() always creates new axes, even if axes kwargs differ.
10361081 fig = plt .figure ()
0 commit comments