Skip to content

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

Merged
simonjayhawkins merged 9 commits into
pandas-dev:masterfrom
simonjayhawkins:doc-fix
Mar 5, 2020
Merged

CI: ax.rowNum and ax.colNum attributes deprecated in Matplotlib 3.2#32444
simonjayhawkins merged 9 commits into
pandas-dev:masterfrom
simonjayhawkins:doc-fix

Conversation

@simonjayhawkins

Copy link
Copy Markdown
Member

@simonjayhawkins simonjayhawkins added the CI Continuous Integration label Mar 4, 2020
@simonjayhawkins

Copy link
Copy Markdown
Member Author

@WillAyd not sure about this. should we just be silencing the deprecation warnings instead. The rowNum attribute was deprecated in Matplotlib 3.2 and will be removed two minor releases later. Use ax.get_subplotspec().rowspan.start instead.

@WillAyd

WillAyd commented Mar 4, 2020

Copy link
Copy Markdown
Member

On a phone so haven’t looked deeply but does swapping out the attribute access for what the message says not work?

@simonjayhawkins

Copy link
Copy Markdown
Member Author

On a phone so haven’t looked deeply but does swapping out the attribute access for what the message says not work?

it doesn't work on older versions. hopefully latest commit fixes but is more complex (may not be relevant).

The alternative is silence the warnings and fix at a later date when the attributes have been deprecated.

@simonjayhawkins

Copy link
Copy Markdown
Member Author

The alternative is silence the warnings and fix at a later date when the attributes have been deprecated.

assuming our minimum supported version has 'SubplotSpec' object has attribute 'rowspan' by then.

@simonjayhawkins

Copy link
Copy Markdown
Member Author

hmm, appears new matplotlib related errors on Linux py37_locale.

@simonjayhawkins

Copy link
Copy Markdown
Member Author

right. fixed warnings in web and docs, but for some reason have two new test failures. have skipped so we can get to ci to green, raise an issue, and resolve independently

@simonjayhawkins simonjayhawkins added this to the 1.0.2 milestone Mar 4, 2020
@simonjayhawkins

Copy link
Copy Markdown
Member Author

@WillAyd I'm not happy with this but I think ok to merge. I think silencing the warnings may be a better approach, but sphinx is not my forte, so I leave that for others to investigate.

@WillAyd

WillAyd commented Mar 5, 2020

Copy link
Copy Markdown
Member

@simonjayhawkins how about just capping matplotlib for now to get CI green then can come back to this at a deeper level (?)

@datapythonista datapythonista left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There is a typo.

And probably worth adding a test, since this only failed in the docs. The next code is what the docs have, calls the affected code and should generate the warning. I think it should be a test good enough (or if you prefer a unit test that calls _handle_shared_axes that should be ok too):

import numpy as np
import pandas as pd
from matplotlib import pyplot as plt

ts = pd.Series(np.random.randn(1000), index=pd.date_range('1/1/2000', periods=1000))
ts = ts.cumsum()

df = pd.DataFrame(np.random.randn(1000, 4), index=ts.index, columns=list('ABCD'))
df = df.cumsum()

fig, axes = plt.subplots(4, 4, figsize=(6, 6))
plt.subplots_adjust(wspace=0.5, hspace=0.5)
target1 = [axes[0][0], axes[1][1], axes[2][2], axes[3][3]]
target2 = [axes[3][0], axes[2][1], axes[1][2], axes[0][3]]

df.plot(subplots=True, ax=target1, legend=False, sharex=False, sharey=False);

Comment thread pandas/plotting/_matplotlib/tools.py Outdated
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
Copy Markdown
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

@simonjayhawkins

Copy link
Copy Markdown
Member Author

There is a typo.

nice catch. Thanks @datapythonista

@simonjayhawkins

Copy link
Copy Markdown
Member Author

And probably worth adding a test

ok as a follow-up if this is green?

@datapythonista

Copy link
Copy Markdown
Member

ok as a follow-up if this is green?

Sure, the docs are being our tests already. Just thought that would be good to see this warning failing the tests. But happy to see the CI fixed asap.

@simonjayhawkins

Copy link
Copy Markdown
Member Author

But happy to see the CI fixed asap.

yeah, if this fails, will go with @WillAyd suggestion, #32444 (comment)

@simonjayhawkins simonjayhawkins merged commit d4cc3cc into pandas-dev:master Mar 5, 2020
meeseeksmachine pushed a commit to meeseeksmachine/pandas that referenced this pull request Mar 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI Continuous Integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants