Closed
Description
Bug summary
setting figure size using the figsize parameter to matplotlib.pyplot.figure works just fine, but setting it to a different value in the same script fails in case the first argument to the figure call is an identifier.
Code for reproduction
import matplotlib.pyplot
# first call
fig = matplotlib.pyplot.figure(1,figsize=(1,2))
fig.get_figheight()
fig.get_figwidth()
# second call
fig = matplotlib.pyplot.figure(1,figsize=(3,4))
fig.get_figheight()
fig.get_figwidth()
Actual outcome
>>> import matplotlib.pyplot
>>> # first call
>>> fig = matplotlib.pyplot.figure(1,figsize=(1,2))
Qt: Session management error: Could not open network socket
>>> fig.get_figheight()
2.0
>>> fig.get_figwidth()
1.0
>>> # second call
>>> fig = matplotlib.pyplot.figure(1,figsize=(3,4))
>>> fig.get_figheight()
2.0
>>> fig.get_figwidth()
1.0
>>>
Expected outcome
The second call should change the figure size and the get_figheight/get_figwidth methods should report the changed size.
Additional information
Note that the problem does not occur if no identifier is provided to the figure call, so this works just fine:
fig = matplotlib.pyplot.figure(figsize=(3,4))
fig.get_figheight()
fig.get_figwidth()
Operating system
Fedora 39 linux
Matplotlib Version
3.8.2
Matplotlib Backend
QtAgg
Python version
Python 3.12.2
Jupyter version
n.a.
Installation
Linux package manager
Metadata
Metadata
Assignees
Labels
No labels