{"action":"created","issue":{"url":"https://api.github.com/repos/ipython/ipython/issues/11167","repository_url":"https://api.github.com/repos/ipython/ipython","labels_url":"https://api.github.com/repos/ipython/ipython/issues/11167/labels{/name}","comments_url":"https://api.github.com/repos/ipython/ipython/issues/11167/comments","events_url":"https://api.github.com/repos/ipython/ipython/issues/11167/events","html_url":"https://github.com/ipython/ipython/issues/11167","id":328731941,"node_id":"MDU6SXNzdWUzMjg3MzE5NDE=","number":11167,"title":"matplotlib.figure.Figure.set_tight_layout gives a warning in Jupyter notebooks","user":{"login":"GergelyKalmar","id":5601876,"node_id":"MDQ6VXNlcjU2MDE4NzY=","avatar_url":"https://avatars3.githubusercontent.com/u/5601876?v=4","gravatar_id":"","url":"https://api.github.com/users/GergelyKalmar","html_url":"https://github.com/GergelyKalmar","followers_url":"https://api.github.com/users/GergelyKalmar/followers","following_url":"https://api.github.com/users/GergelyKalmar/following{/other_user}","gists_url":"https://api.github.com/users/GergelyKalmar/gists{/gist_id}","starred_url":"https://api.github.com/users/GergelyKalmar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GergelyKalmar/subscriptions","organizations_url":"https://api.github.com/users/GergelyKalmar/orgs","repos_url":"https://api.github.com/users/GergelyKalmar/repos","events_url":"https://api.github.com/users/GergelyKalmar/events{/privacy}","received_events_url":"https://api.github.com/users/GergelyKalmar/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-06-02T10:10:02Z","updated_at":"2018-06-02T20:29:56Z","closed_at":null,"author_association":"NONE","body":"The following code in a Jupyter notebook produces a warning:\r\n```\r\n%matplotlib inline\r\nimport matplotlib.pyplot as plt\r\nfig, ax = plt.subplots()\r\nfig.set_tight_layout({'pad': 1})\r\nax.plot(range(10))\r\n```\r\n\r\n```\r\n~/.env/lara/lib/python3.5/site-packages/matplotlib/figure.py:2267: UserWarning: This figure includes Axes that are not compatible with tight_layout, so results might be incorrect.\r\n  warnings.warn(\"This figure includes Axes that are not compatible \"\r\n```\r\n\r\nInterestingly the warning does not appear when one is using fig.tight_layout(...). It seems to be caused by an axes passed to get_subplotspec_list(...) that does not have a subplotspec. The warning does not appear when the same code is executed in a standalone python script, hence the issue is likely related to ipython. The resulting plot is not affected by the warning but it's still annoying.\r\n\r\nAll packages are the latest version:\r\nmatplotlib==2.2.2\r\njupyter-client==5.2.3\r\njupyter-core==4.4.0\r\njupyterlab==0.32.1\r\njupyterlab-launcher==0.10.5\r\nipython==6.4.0\r\nipython-genutils==0.2.0"},"comment":{"url":"https://api.github.com/repos/ipython/ipython/issues/comments/394115027","html_url":"https://github.com/ipython/ipython/issues/11167#issuecomment-394115027","issue_url":"https://api.github.com/repos/ipython/ipython/issues/11167","id":394115027,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NDExNTAyNw==","user":{"login":"GergelyKalmar","id":5601876,"node_id":"MDQ6VXNlcjU2MDE4NzY=","avatar_url":"https://avatars3.githubusercontent.com/u/5601876?v=4","gravatar_id":"","url":"https://api.github.com/users/GergelyKalmar","html_url":"https://github.com/GergelyKalmar","followers_url":"https://api.github.com/users/GergelyKalmar/followers","following_url":"https://api.github.com/users/GergelyKalmar/following{/other_user}","gists_url":"https://api.github.com/users/GergelyKalmar/gists{/gist_id}","starred_url":"https://api.github.com/users/GergelyKalmar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GergelyKalmar/subscriptions","organizations_url":"https://api.github.com/users/GergelyKalmar/orgs","repos_url":"https://api.github.com/users/GergelyKalmar/repos","events_url":"https://api.github.com/users/GergelyKalmar/events{/privacy}","received_events_url":"https://api.github.com/users/GergelyKalmar/received_events","type":"User","site_admin":false},"created_at":"2018-06-02T20:29:55Z","updated_at":"2018-06-02T20:29:55Z","author_association":"NONE","body":"A possible workaround for now is to just suppress the warning, however, this may also suppress the warning when it is legitimate:\r\n```\r\nimport warnings\r\nwarnings.filterwarnings(\r\n    action='ignore', module='matplotlib.figure', category=UserWarning,\r\n    message=('This figure includes Axes that are not compatible with tight_layout, '\r\n             'so results might be incorrect.')\r\n)\r\n```"}}
{"actor":{"display_login":"GergelyKalmar"}}