Repository navigation
Closed
Milestone
Description
Bug summary
Creating a figure via plt.figure() with matplotlib version 3.6.0 results in a MatplotlibDeprecationWarning. I see this on macOS (both M1 and Intel) and have not managed to reproduce this in a few other container environments I tried.
Code for reproduction
import matplotlib.pyplot as plt
plt.figure()Actual outcome
/private/tmp/mpl/test.py:3: MatplotlibDeprecationWarning: The resize_event function was deprecated in Matplotlib 3.6 and will be removed two minor releases later. Use callbacks.process('resize_event', ResizeEvent(...)) instead.
plt.figure()
Expected outcome
no warning raised
Additional information
I have not managed to reproduce this in any containers, so perhaps this is specific to the macosx backend. No warnings appear in earlier versions. I can reproduce the behavior also in new conda environments and virtual environments, here is a full example:
/tmp/mpl ❯ ls
/tmp/mpl ❯ pipx run virtualenv venv
created virtual environment CPython3.10.4.final.0-64 in 159ms
creator CPython3Posix(dest=/private/tmp/mpl/venv, clear=False, no_vcs_ignore=False, global=False)
seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/Users/alheld/Library/Application Support/virtualenv)
added seed packages: pip==22.2.2, setuptools==65.3.0, wheel==0.37.1
activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
/tmp/mpl ❯ source venv/bin/activate
/tmp/mpl ❯ python --version
Python 3.10.4
/tmp/mpl ❯ which python
/private/tmp/mpl/venv/bin/python
/tmp/mpl ❯ pip install matplotlib
Collecting matplotlib
Using cached matplotlib-3.6.0-cp310-cp310-macosx_11_0_arm64.whl (7.2 MB)
Collecting pillow>=6.2.0
Using cached Pillow-9.2.0-cp310-cp310-macosx_11_0_arm64.whl (2.8 MB)
Collecting numpy>=1.19
Using cached numpy-1.23.3-cp310-cp310-macosx_11_0_arm64.whl (13.3 MB)
Collecting packaging>=20.0
Using cached packaging-21.3-py3-none-any.whl (40 kB)
Collecting python-dateutil>=2.7
Using cached python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
Collecting cycler>=0.10
Using cached cycler-0.11.0-py3-none-any.whl (6.4 kB)
Collecting fonttools>=4.22.0
Using cached fonttools-4.37.2-py3-none-any.whl (959 kB)
Collecting contourpy>=1.0.1
Using cached contourpy-1.0.5-cp310-cp310-macosx_11_0_arm64.whl (226 kB)
Collecting pyparsing>=2.2.1
Using cached pyparsing-3.0.9-py3-none-any.whl (98 kB)
Collecting kiwisolver>=1.0.1
Using cached kiwisolver-1.4.4-cp310-cp310-macosx_11_0_arm64.whl (63 kB)
Collecting six>=1.5
Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Installing collected packages: six, pyparsing, pillow, numpy, kiwisolver, fonttools, cycler, python-dateutil, packaging, contourpy, matplotlib
Successfully installed contourpy-1.0.5 cycler-0.11.0 fonttools-4.37.2 kiwisolver-1.4.4 matplotlib-3.6.0 numpy-1.23.3 packaging-21.3 pillow-9.2.0 pyparsing-3.0.9 python-dateutil-2.8.2 six-1.16.0
/tmp/mpl ❯ python -c "import matplotlib.pyplot as plt; import matplotlib as mpl; print(mpl.__version__); plt.figure()"
3.6.0
<string>:1: MatplotlibDeprecationWarning: The resize_event function was deprecated in Matplotlib 3.6 and will be removed two minor releases later. Use callbacks.process('resize_event', ResizeEvent(...)) instead.Operating system
macOS 12.5.1
Matplotlib Version
3.6.0
Matplotlib Backend
MacOSX
Python version
Python 3.10.4
Jupyter version
n/a
Installation
pip
Reacted by Anders Goncalves da Silva, Ben, Alessandro Quirile, Volkov Maxim, Cole Lewis, Roland Laurès and Max Humber
Activity
[-][Bug]: resize_event deprecation warnings when creating figure on macOS[/-][+][Bug]: resize_event deprecation warnings when creating figure on macOS with version 3.6.0[/+]erykoff commentedon Sep 17, 2022
I also see this on the first call to even as something simple as
plt.plot([0, 1], [0, 1]).andersgs commentedon Sep 17, 2022
+1
jklymak commentedon Sep 18, 2022
This will be fixed in 3.6.1. For major releases like 3.6, the bug fix release is usually relatively soon.
YaolinGe commentedon Dec 21, 2022
It still happens on 3.6.2 on my mac in PyCharm Pro IDE.
Any updates?
tacaswell commentedon Dec 21, 2022
@YaolinGe I can not reproduce this outside of pycharm. Can you produce not launched through pycharm? If so can you please open a new issue?
YaolinGe commentedon Jan 5, 2023
@tacaswell I cannot reproduce this neither outside of pycharm. So it is a pycharm issue?
tacaswell commentedon Jan 5, 2023
Yes, please report this to jetbrains.
They have their own backend which may be the call site.
Attn @oscargus
mivanc commentedon Feb 9, 2023
I received similar MatplotlibDeprecationWarning when using pp.close(_fig):
MatplotlibDeprecationWarning: The close_event function was deprecated in Matplotlib 3.6 and will be removed two minor releases later. Use callbacks.process('close_event', CloseEvent(...)) instead.
I am using WSL1, python 3.11.1, matplotlib==3.6.2 and matplotlib.use('nbAgg').
I was not able to find any instructions how to close the figure differently.