@@ -287,6 +287,20 @@ def test_suptitle_fontproperties():
287287 assert txt .get_weight () == fps .get_weight ()
288288
289289
290+ def test_suptitle_subfigures ():
291+ fig = plt .figure (figsize = (4 , 3 ))
292+ sf1 , sf2 = fig .subfigures (1 , 2 )
293+ sf2 .set_facecolor ('white' )
294+ sf1 .subplots ()
295+ sf2 .subplots ()
296+ fig .suptitle ("This is a visible suptitle." )
297+
298+ # verify the first subfigure facecolor is the default transparent
299+ assert sf1 .get_facecolor () == (0.0 , 0.0 , 0.0 , 0.0 )
300+ # verify the second subfigure facecolor is white
301+ assert sf2 .get_facecolor () == (1.0 , 1.0 , 1.0 , 1.0 )
302+
303+
290304@image_comparison (['alpha_background' ],
291305 # only test png and svg. The PDF output appears correct,
292306 # but Ghostscript does not preserve the background color.
@@ -1211,12 +1225,14 @@ def test_subfigure():
12111225 pc = ax .pcolormesh (np .random .randn (30 , 30 ), vmin = - 2 , vmax = 2 )
12121226 sub [0 ].colorbar (pc , ax = axs )
12131227 sub [0 ].suptitle ('Left Side' )
1228+ sub [0 ].set_facecolor ('white' )
12141229
12151230 axs = sub [1 ].subplots (1 , 3 )
12161231 for ax in axs .flat :
12171232 pc = ax .pcolormesh (np .random .randn (30 , 30 ), vmin = - 2 , vmax = 2 )
12181233 sub [1 ].colorbar (pc , ax = axs , location = 'bottom' )
12191234 sub [1 ].suptitle ('Right Side' )
1235+ sub [1 ].set_facecolor ('white' )
12201236
12211237 fig .suptitle ('Figure suptitle' , fontsize = 'xx-large' )
12221238
0 commit comments