@@ -1782,6 +1782,17 @@ def test_labels(self, long_df):
17821782
17831783class TestLabelVisibility :
17841784
1785+ def has_xaxis_labels (self , ax ):
1786+ if _version_predates (mpl , "3.7" ):
1787+ # mpl3.7 added a getter for tick params, but both yaxis and xaxis return
1788+ # the same entry of "labelleft" instead of "labelbottom" for xaxis
1789+ return len (ax .get_xticklabels ()) > 0
1790+ elif _version_predates (mpl , "3.10" ):
1791+ # Then I guess they made it labelbottom in 3.10?
1792+ return ax .xaxis .get_tick_params ()["labelleft" ]
1793+ else :
1794+ return ax .xaxis .get_tick_params ()["labelbottom" ]
1795+
17851796 def test_single_subplot (self , long_df ):
17861797
17871798 x , y = "a" , "z"
@@ -1852,12 +1863,7 @@ def test_1d_column_wrapped(self):
18521863 for s in subplots [1 :]:
18531864 ax = s ["ax" ]
18541865 assert ax .xaxis .get_label ().get_visible ()
1855- # mpl3.7 added a getter for tick params, but both yaxis and xaxis return
1856- # the same entry of "labelleft" instead of "labelbottom" for xaxis
1857- if not _version_predates (mpl , "3.7" ):
1858- assert ax .xaxis .get_tick_params ()["labelleft" ]
1859- else :
1860- assert len (ax .get_xticklabels ()) > 0
1866+ assert self .has_xaxis_labels (ax )
18611867 assert all (t .get_visible () for t in ax .get_xticklabels ())
18621868
18631869 for s in subplots [1 :- 1 ]:
@@ -1882,12 +1888,7 @@ def test_1d_row_wrapped(self):
18821888 for s in subplots [- 2 :]:
18831889 ax = s ["ax" ]
18841890 assert ax .xaxis .get_label ().get_visible ()
1885- # mpl3.7 added a getter for tick params, but both yaxis and xaxis return
1886- # the same entry of "labelleft" instead of "labelbottom" for xaxis
1887- if not _version_predates (mpl , "3.7" ):
1888- assert ax .xaxis .get_tick_params ()["labelleft" ]
1889- else :
1890- assert len (ax .get_xticklabels ()) > 0
1891+ assert self .has_xaxis_labels (ax )
18911892 assert all (t .get_visible () for t in ax .get_xticklabels ())
18921893
18931894 for s in subplots [:- 2 ]:
0 commit comments