Skip to content

CI: ax.rowNum and ax.colNum attributes deprecated in Matplotlib 3.2 #32444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Mar 5, 2020
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions pandas/plotting/_matplotlib/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
from pandas.core.dtypes.common import is_list_like
from pandas.core.dtypes.generic import ABCDataFrame, ABCIndexClass, ABCSeries

from pandas.plotting._matplotlib import compat


def format_date_labels(ax, rot):
# mini version of autofmt_xdate
Expand Down Expand Up @@ -288,20 +290,26 @@ def _remove_labels_from_axis(axis):

def _handle_shared_axes(axarr, nplots, naxes, nrows, ncols, sharex, sharey):
if nplots > 1:
if compat._mpl_ge_3_2_0():
row_num = lambda x: x.get_subplotspec().rowspan.start
col_num = lambda x: x.get_subplotspec().rowspan.start
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
col_num = lambda x: x.get_subplotspec().rowspan.start
col_num = lambda x: x.get_subplotspec().colspan.start

else:
row_num = lambda x: x.rowNum
col_num = lambda x: x.colNum

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

for ax in axarr:
# only the last row of subplots should get x labels -> all
# other off layout handles the case that the subplot is
# the last in the column, because below is no subplot/gap.
if not layout[ax.rowNum + 1, ax.colNum]:
if not layout[row_num(ax) + 1, col_num(ax)]:
continue
if sharex or len(ax.get_shared_x_axes().get_siblings(ax)) > 1:
_remove_labels_from_axis(ax.xaxis)
Expand Down
7 changes: 7 additions & 0 deletions pandas/tests/plotting/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,9 @@ def test_groupby_boxplot_sharex(self):
# sharex can now be switched check whether the right
# pair of axes is turned on or off

if self.mpl_ge_3_2_0:
pytest.skip("https://github.com/pandas-dev/pandas/pull/32444")

df = DataFrame(
{
"a": [-1.43, -0.15, -3.70, -1.43, -0.14],
Expand Down Expand Up @@ -744,6 +747,10 @@ def test_subplots_ts_share_axes(self):

def test_subplots_sharex_axes_existing_axes(self):
# GH 9158

if self.mpl_ge_3_2_0:
pytest.skip("https://github.com/pandas-dev/pandas/pull/32444")

d = {"A": [1.0, 2.0, 3.0, 4.0], "B": [4.0, 3.0, 2.0, 1.0], "C": [5, 1, 3, 4]}
df = DataFrame(d, index=date_range("2014 10 11", "2014 10 14"))

Expand Down