MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / _raise_if_figure_exists

Function _raise_if_figure_exists

lib/matplotlib/pyplot.py:1186–1202  ·  view source on GitHub ↗

Raise a ValueError if the figure *num* already exists.

(num, func_name, clear=False)

Source from the content-addressed store, hash-verified

1184
1185
1186def _raise_if_figure_exists(num, func_name, clear=False):
1187 """
1188 Raise a ValueError if the figure *num* already exists.
1189 """
1190 if num is not None and not clear:
1191 if isinstance(num, FigureBase):
1192 raise ValueError(
1193 f"num {num!r} cannot be a FigureBase instance. "
1194 f"plt.{func_name}() is for creating new figures. "
1195 f"To add to an existing figure, use fig.{func_name}() "
1196 "instead.")
1197
1198 if fignum_exists(num):
1199 raise ValueError(
1200 f"Figure {num!r} already exists. Use plt.figure({num!r}) "
1201 f"to get it or plt.close({num!r}) to close it. "
1202 f"Alternatively, pass 'clear=True' to {func_name}().")
1203
1204
1205def get_fignums() -> list[int]:

Callers 2

subplotsFunction · 0.85
subplot_mosaicFunction · 0.85

Calls 1

fignum_existsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…