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

Conversation

simonjayhawkins
Copy link
Member

@simonjayhawkins simonjayhawkins added the CI Continuous Integration label Mar 4, 2020
@simonjayhawkins
Copy link
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
Copy link
Member

WillAyd commented Mar 4, 2020

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
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
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
Member Author

hmm, appears new matplotlib related errors on Linux py37_locale.

@simonjayhawkins
Copy link
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
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
Copy link
Member

WillAyd commented Mar 5, 2020

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

Copy link
Member

@datapythonista datapythonista left a comment

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);

@@ -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

@simonjayhawkins
Copy link
Member Author

There is a typo.

nice catch. Thanks @datapythonista

@simonjayhawkins
Copy link
Member Author

And probably worth adding a test

ok as a follow-up if this is green?

@datapythonista
Copy link
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
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