@@ -214,20 +214,35 @@ def test_subplot_factory_reapplication():
214
214
assert maxes .subplot_class_factory (maxes .Subplot ) is maxes .Subplot
215
215
216
216
217
+ @pytest .mark .parametrize ("width_ratios" , [None , [1 , 3 , 2 ]])
218
+ @pytest .mark .parametrize ("height_ratios" , [None , [1 , 2 ]])
217
219
@check_figures_equal (extensions = ['png' ])
218
- def test_width_and_height_ratios (fig_test , fig_ref ):
219
- fig_test .subplots (2 , 3 , height_ratios = [1 , 2 ],
220
- width_ratios = [1 , 3 , 2 ])
220
+ def test_width_and_height_ratios (fig_test , fig_ref ,
221
+ height_ratios , width_ratios ):
222
+ fig_test .subplots (2 , 3 , height_ratios = height_ratios ,
223
+ width_ratios = width_ratios )
221
224
fig_ref .subplots (2 , 3 , gridspec_kw = {
222
- 'height_ratios' : [ 1 , 2 ] ,
223
- 'width_ratios' : [ 1 , 3 , 2 ] })
225
+ 'height_ratios' : height_ratios ,
226
+ 'width_ratios' : width_ratios })
224
227
225
228
229
+ @pytest .mark .parametrize ("width_ratios" , [None , [1 , 3 , 2 ]])
230
+ @pytest .mark .parametrize ("height_ratios" , [None , [1 , 2 ]])
226
231
@check_figures_equal (extensions = ['png' ])
227
- def test_width_and_height_ratios_mosaic (fig_test , fig_ref ):
232
+ def test_width_and_height_ratios_mosaic (fig_test , fig_ref ,
233
+ height_ratios , width_ratios ):
228
234
mosaic_spec = [['A' , 'B' , 'B' ], ['A' , 'C' , 'D' ]]
229
- fig_test .subplot_mosaic (mosaic_spec , height_ratios = [ 1 , 2 ] ,
230
- width_ratios = [ 1 , 3 , 2 ] )
235
+ fig_test .subplot_mosaic (mosaic_spec , height_ratios = height_ratios ,
236
+ width_ratios = width_ratios )
231
237
fig_ref .subplot_mosaic (mosaic_spec , gridspec_kw = {
232
- 'height_ratios' : [1 , 2 ],
233
- 'width_ratios' : [1 , 3 , 2 ]})
238
+ 'height_ratios' : height_ratios ,
239
+ 'width_ratios' : width_ratios })
240
+
241
+
242
+ def test_ratio_overlapping_kws ():
243
+ with pytest .raises (ValueError , match = 'height_ratios' ):
244
+ plt .subplots (2 , 3 , height_ratios = [1 , 2 ],
245
+ gridspec_kw = {'height_ratios' :[1 ,2 ]})
246
+ with pytest .raises (ValueError , match = 'width_ratios' ):
247
+ plt .subplots (2 , 3 , width_ratios = [1 , 2 , 3 ],
248
+ gridspec_kw = {'width_ratios' :[1 , 2 , 3 ]})
0 commit comments