22
22
_check_ticks_props ,
23
23
_check_visible ,
24
24
)
25
+ from pandas .util .version import Version
25
26
26
27
from pandas .io .formats .printing import pprint_thing
27
28
@@ -35,6 +36,17 @@ def _check_ax_limits(col, ax):
35
36
assert y_max >= col .max ()
36
37
37
38
39
+ if Version (mpl ._version__ ) < Version ("3.10" ):
40
+ verts = [{"vert" : False }, {"vert" : True }]
41
+ else :
42
+ verts = [{"orientation" : "horizontal" }, {"orientation" : "vertical" }]
43
+
44
+
45
+ @pytest .fixture (params = verts )
46
+ def vert (request ):
47
+ return request .param
48
+
49
+
38
50
class TestDataFramePlots :
39
51
def test_stacked_boxplot_set_axis (self ):
40
52
# GH2980
@@ -312,7 +324,6 @@ def test_specified_props_kwd(self, props, expected):
312
324
313
325
assert result [expected ][0 ].get_color () == "C1"
314
326
315
- @pytest .mark .parametrize ("vert" , [True , False ])
316
327
def test_plot_xlabel_ylabel (self , vert ):
317
328
df = DataFrame (
318
329
{
@@ -322,11 +333,10 @@ def test_plot_xlabel_ylabel(self, vert):
322
333
}
323
334
)
324
335
xlabel , ylabel = "x" , "y"
325
- ax = df .plot (kind = "box" , vert = vert , xlabel = xlabel , ylabel = ylabel )
336
+ ax = df .plot (kind = "box" , xlabel = xlabel , ylabel = ylabel , ** vert )
326
337
assert ax .get_xlabel () == xlabel
327
338
assert ax .get_ylabel () == ylabel
328
339
329
- @pytest .mark .parametrize ("vert" , [True , False ])
330
340
def test_plot_box (self , vert ):
331
341
# GH 54941
332
342
rng = np .random .default_rng (2 )
@@ -335,13 +345,12 @@ def test_plot_box(self, vert):
335
345
336
346
xlabel , ylabel = "x" , "y"
337
347
_ , axs = plt .subplots (ncols = 2 , figsize = (10 , 7 ), sharey = True )
338
- df1 .plot .box (ax = axs [0 ], vert = vert , xlabel = xlabel , ylabel = ylabel )
339
- df2 .plot .box (ax = axs [1 ], vert = vert , xlabel = xlabel , ylabel = ylabel )
348
+ df1 .plot .box (ax = axs [0 ], xlabel = xlabel , ylabel = ylabel , ** vert )
349
+ df2 .plot .box (ax = axs [1 ], xlabel = xlabel , ylabel = ylabel , ** vert )
340
350
for ax in axs :
341
351
assert ax .get_xlabel () == xlabel
342
352
assert ax .get_ylabel () == ylabel
343
353
344
- @pytest .mark .parametrize ("vert" , [True , False ])
345
354
def test_boxplot_xlabel_ylabel (self , vert ):
346
355
df = DataFrame (
347
356
{
@@ -351,11 +360,10 @@ def test_boxplot_xlabel_ylabel(self, vert):
351
360
}
352
361
)
353
362
xlabel , ylabel = "x" , "y"
354
- ax = df .boxplot (vert = vert , xlabel = xlabel , ylabel = ylabel )
363
+ ax = df .boxplot (xlabel = xlabel , ylabel = ylabel , ** vert )
355
364
assert ax .get_xlabel () == xlabel
356
365
assert ax .get_ylabel () == ylabel
357
366
358
- @pytest .mark .parametrize ("vert" , [True , False ])
359
367
def test_boxplot_group_xlabel_ylabel (self , vert ):
360
368
df = DataFrame (
361
369
{
@@ -365,7 +373,7 @@ def test_boxplot_group_xlabel_ylabel(self, vert):
365
373
}
366
374
)
367
375
xlabel , ylabel = "x" , "y"
368
- ax = df .boxplot (by = "group" , vert = vert , xlabel = xlabel , ylabel = ylabel )
376
+ ax = df .boxplot (by = "group" , xlabel = xlabel , ylabel = ylabel , ** vert )
369
377
for subplot in ax :
370
378
assert subplot .get_xlabel () == xlabel
371
379
assert subplot .get_ylabel () == ylabel
0 commit comments