Skip to content

Figure N #314

@mandli

Description

@mandli

I have been getting this UserWarning from matplotlib and VisClaw lately:

clawpack/visclaw/src/python/visclaw/frametools.py:171: UserWarning: Ignoring specified arguments in this call because figure with num: 1006 already exists
  plotfigure._handle = plt.figure(num=figno, **plotfigure.kwargs)

It may be occurring due to a change in matplotlib, but I think there is a larger problem that needs to be addressed. The addition of key-word arguments is the cause of the problem, and can be recreated by

import matplotlib.pyplot as plt
plt.figure(num=1)
plt.figure(num=1, **{'figsize': (6.4, 4.8)})

I see two fixes for this:

  1. close (delete) the figure and create a new one, or
  2. see if the figure exists and do not apply the key-word arguments (or maybe we do).

The first is probably the safest but the positions and sizes of windows may not be maintained during interactive plotting. The second would not allow key-word arguments to be re-applied but would maintain the state. Probably bears some testing to fix this.

Versions for reference:
Python 3.13.2
matplotlib.version = '3.10.0'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions