Skip to content

Commit 53f9908

Browse files
Backport PR pandas-dev#32444: CI: ax.rowNum and ax.colNum attributes deprecated in Matplotlib 3.2 (pandas-dev#32456)
Co-authored-by: Simon Hawkins <[email protected]>
1 parent bda5f4b commit 53f9908

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

pandas/plotting/_matplotlib/tools.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
from pandas.core.dtypes.common import is_list_like
1010
from pandas.core.dtypes.generic import ABCDataFrame, ABCIndexClass, ABCSeries
1111

12+
from pandas.plotting._matplotlib import compat
13+
1214

1315
def format_date_labels(ax, rot):
1416
# mini version of autofmt_xdate
@@ -288,20 +290,26 @@ def _remove_labels_from_axis(axis):
288290

289291
def _handle_shared_axes(axarr, nplots, naxes, nrows, ncols, sharex, sharey):
290292
if nplots > 1:
293+
if compat._mpl_ge_3_2_0():
294+
row_num = lambda x: x.get_subplotspec().rowspan.start
295+
col_num = lambda x: x.get_subplotspec().colspan.start
296+
else:
297+
row_num = lambda x: x.rowNum
298+
col_num = lambda x: x.colNum
291299

292300
if nrows > 1:
293301
try:
294302
# first find out the ax layout,
295303
# so that we can correctly handle 'gaps"
296304
layout = np.zeros((nrows + 1, ncols + 1), dtype=np.bool)
297305
for ax in axarr:
298-
layout[ax.rowNum, ax.colNum] = ax.get_visible()
306+
layout[row_num(ax), col_num(ax)] = ax.get_visible()
299307

300308
for ax in axarr:
301309
# only the last row of subplots should get x labels -> all
302310
# other off layout handles the case that the subplot is
303311
# the last in the column, because below is no subplot/gap.
304-
if not layout[ax.rowNum + 1, ax.colNum]:
312+
if not layout[row_num(ax) + 1, col_num(ax)]:
305313
continue
306314
if sharex or len(ax.get_shared_x_axes().get_siblings(ax)) > 1:
307315
_remove_labels_from_axis(ax.xaxis)

0 commit comments

Comments
 (0)