Skip to content

Commit 52b8459

Browse files
authored
COMPAT: matplotlib 3.4.0 (#40718)
1 parent 694d058 commit 52b8459

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

pandas/plotting/_matplotlib/compat.py

+1
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ def inner():
2222
mpl_ge_3_1_0 = _mpl_version("3.1.0", operator.ge)
2323
mpl_ge_3_2_0 = _mpl_version("3.2.0", operator.ge)
2424
mpl_ge_3_3_0 = _mpl_version("3.3.0", operator.ge)
25+
mpl_ge_3_4_0 = _mpl_version("3.4.0", operator.ge)

pandas/plotting/_matplotlib/tools.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,11 @@ def handle_shared_axes(
392392
row_num = lambda x: x.rowNum
393393
col_num = lambda x: x.colNum
394394

395+
if compat.mpl_ge_3_4_0():
396+
is_first_col = lambda x: x.get_subplotspec().is_first_col()
397+
else:
398+
is_first_col = lambda x: x.is_first_col()
399+
395400
if nrows > 1:
396401
try:
397402
# first find out the ax layout,
@@ -423,7 +428,7 @@ def handle_shared_axes(
423428
# only the first column should get y labels -> set all other to
424429
# off as we only have labels in the first column and we always
425430
# have a subplot there, we can skip the layout test
426-
if ax.is_first_col():
431+
if is_first_col(ax):
427432
continue
428433
if sharey or _has_externally_shared_axis(ax, "y"):
429434
_remove_labels_from_axis(ax.yaxis)

pandas/tests/plotting/frame/test_frame.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,9 @@ def test_plot_scatter_with_categorical_data(self, x, y):
746746

747747
_check_plot_works(df.plot.scatter, x=x, y=y)
748748

749-
def test_plot_scatter_with_c(self):
749+
def test_plot_scatter_with_c(self, request):
750+
from pandas.plotting._matplotlib.compat import mpl_ge_3_4_0
751+
750752
df = DataFrame(
751753
np.random.randn(6, 4),
752754
index=list(string.ascii_letters[:6]),
@@ -758,9 +760,10 @@ def test_plot_scatter_with_c(self):
758760
# default to Greys
759761
assert ax.collections[0].cmap.name == "Greys"
760762

761-
# n.b. there appears to be no public method
762-
# to get the colorbar label
763-
assert ax.collections[0].colorbar._label == "z"
763+
if mpl_ge_3_4_0():
764+
assert ax.collections[0].colorbar.ax.get_ylabel() == "z"
765+
else:
766+
assert ax.collections[0].colorbar._label == "z"
764767

765768
cm = "cubehelix"
766769
ax = df.plot.scatter(x="x", y="y", c="z", colormap=cm)

0 commit comments

Comments
 (0)