Skip to content

Pandas enforces subplot_adjust creating UserWarning with constrained_layout #16464

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

Closed
michaelaye opened this issue Feb 10, 2020 · 9 comments
Closed

Comments

@michaelaye
Copy link

Bug report

Bug summary

Pandas dataframe plotting uses subplot_adjust, always creating a UserWarning because I am using constrained_layout as my default layouter.

Cross-issue with pandas-dev/pandas#25261 (I'm uncertain where this should/could be fixed).

Code for reproduction

import matplotlib as mpl
mpl.rcParams['figure.constrained_layout.use'] = True
tseries = pd.date_range('now', freq='s', periods=100)
df = pd.DataFrame({'data': np.random.random(100)}, index=tseries)
df.plot()

Actual outcome

Screenshot 2020-02-10 09 55 00

Expected outcome

No UserWarning

Matplotlib version

  • Operating system: macOS 10.14.6
  • Matplotlib version: 3.1.3
  • Matplotlib backend (print(matplotlib.get_backend())): 'module://ipykernel.pylab.backend_inline'
  • Python version: 3.7.6
  • Jupyter version (if applicable): Jupyterlab 1.2.6
  • Other libraries:

All installed via conda-forge.

@jklymak
Copy link
Member

jklymak commented Feb 10, 2020

This is how constrained_layout is supposed to work - if the user manually adjusts the subplots, it stops trying to do things automatically.

@michaelaye
Copy link
Author

With user you mean pandas here, I guess?

@jklymak
Copy link
Member

jklymak commented Feb 10, 2020

Any user or any package calling subplots_adjust.

@michaelaye
Copy link
Author

Ok. My point here is that it's out of the user's hand. Pandas just does the subplots_adjust, therefore any user of the constrained_layout feature constantly gets these UserWarnings.

@jklymak
Copy link
Member

jklymak commented Feb 10, 2020

Matplotlib is working as designed, so I guess the question is what change would you hope for on our end? The only two I can think of are a) we don't emit a UserWarning, but I think the warning is needed in this case, or b) we ignore subplots_adjust. But I think we can't really do that as people have perfectly valid reasons for manually adjusting their plots, and don't want some more general setting overriding the more specific.

From the panda's side they could not call subplots_adjust if constrained_layout is True.

@michaelaye
Copy link
Author

I tend to agree, but the matplotlib twitter account encouraged me to create this issue and link it to the pandas' one. ;)

@story645
Copy link
Member

I figured this is a common enough bug that it's useful to be documented here 🤷‍♀

@github-actions
Copy link

This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

@github-actions github-actions bot added the status: inactive Marked by the “Stale” Github Action label Jul 10, 2023
@story645
Copy link
Member

This doesn't seem to happen anymore due to changes in Matplotlib or Pandas.

@story645 story645 closed this as not planned Won't fix, can't repro, duplicate, stale Jul 10, 2023
@rcomer rcomer removed the status: inactive Marked by the “Stale” Github Action label Jul 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants