FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[Bug]: Constrained layout UserWarning even when False · Issue #23986 · matplotlib/matplotlib · GitHub

Repository navigation

[Bug]: Constrained layout UserWarning even when False #23986

Closed

Description

Bug summary

When using layout settings such as plt.subplots_adjust or bbox_inches='tight, a UserWarning is produced due to incompatibility with constrained_layout, even if constrained_layout = False. This was not the case in previous versions.

Code for reproduction

import matplotlib.pyplot as plt
import numpy as np
a = np.linspace(0,2*np.pi,100)
b = np.sin(a)
c = np.cos(a)
fig,ax = plt.subplots(1,2,figsize=(8,2),constrained_layout=False)
ax[0].plot(a,b)
ax[1].plot(a,c)
plt.subplots_adjust(wspace=0)

Actual outcome

The plot works fine but the warning is generated

/var/folders/ss/pfgdfm2x7_s4cyw2v0b_t7q80000gn/T/ipykernel_76923/4170965423.py:7: UserWarning: This figure was using a layout engine that is incompatible with subplots_adjust and/or tight_layout; not calling subplots_adjust. plt.subplots_adjust(wspace=0)

Expected outcome

no warning

Additional information

Warning disappears when constrained_layout=False is removed

Operating system

OS/X

Matplotlib Version

3.6.0

Matplotlib Backend

No response

Python version

No response

Jupyter version

No response

Installation

conda

Activity

  1. added this to the v3.6.1 milestone on Sep 22, 2022
  2. tacaswell commented on Sep 22, 2022

    Member

    Yup, that is indeed a bug

    elif constrained_layout is not None:
    self.set_layout_engine(layout='constrained')
    if isinstance(constrained_layout, dict):
    self.get_layout_engine().set(**constrained_layout)

    PR on the way.

  3. tacaswell commented on Sep 22, 2022

    Member

    @VanWieren Did you mean to close this? We normally keep bugs open until the PR to fix it is actually merged.

  4. VanWieren commented on Sep 22, 2022

    Author

    @VanWieren Did you mean to close this? We normally keep bugs open until the PR to fix it is actually merged.

    oh oops, I did not know that. Will reopen

  5. tacaswell commented on Sep 22, 2022

    Member

    No worries! Saying "I'll fix this" is way easier than actually fixing it (for example in this case I thought it would be super simple, but then I found a bunch of complications....).

    By keeping the issue open we can track that it is not really fixed, the PR will link to this and we use the github cross-ref tools to automatically

  6. added a commit that references this issue on Sep 22, 2022
    5efddd3
  7. added a commit that references this issue on Dec 19, 2022
    d6a3487
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL