Skip to content

Commit 0433bd5

Browse files
committed
Rename rcParam to figure.max_open_warning. Rewrite warning message.
1 parent 8c8bc8f commit 0433bd5

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

lib/matplotlib/pyplot.py

+10-8
Original file line numberDiff line numberDiff line change
@@ -394,16 +394,18 @@ def figure(num=None, # autoincrement if None, else integer from 1-N
394394

395395
figManager = _pylab_helpers.Gcf.get_fig_manager(num)
396396
if figManager is None:
397-
max_num_figures = rcParams['figure.max_num_figures']
397+
max_open_warning = rcParams['figure.max_open_warning']
398398

399-
if (max_num_figures >= 1 and
400-
len(allnums) >= max_num_figures):
399+
if (max_open_warning >= 1 and
400+
len(allnums) >= max_open_warning):
401401
warnings.warn(
402-
"More than %d figures have been opened. Figures created "
403-
"through the pyplot interface are retained until explicitly "
404-
"closed. (To control this warning, see the rcParam "
405-
"'figure.max_num_figures'." %
406-
max_num_figures, RuntimeWarning)
402+
"More than %d figures have been opened. Figures "
403+
"created through the pyplot interface "
404+
"(`matplotlib.pyplot.figure`) are retained until "
405+
"explicitly closed and may consume too much memory. "
406+
"(To control this warning, see the rcParam "
407+
"`figure.max_num_figures`)." %
408+
max_open_warning, RuntimeWarning)
407409

408410
if get_backend().lower() == 'ps':
409411
dpi = 72

lib/matplotlib/rcsetup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ def __call__(self, s):
680680
'figure.edgecolor': ['w', validate_color], # edgecolor; white
681681
'figure.frameon': [True, validate_bool],
682682
'figure.autolayout': [False, validate_bool],
683-
'figure.max_num_figures': [20, validate_int],
683+
'figure.max_open_warning': [20, validate_int],
684684

685685
'figure.subplot.left': [0.125, ValidateInterval(0, 1, closedmin=True,
686686
closedmax=True)],

matplotlibrc.template

+3-3
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,9 @@ text.hinting_factor : 8 # Specifies the amount of softness for hinting in the
318318
#figure.edgecolor : white # figure edgecolor
319319
#figure.autolayout : False # When True, automatically adjust subplot
320320
# parameters to make the plot fit the figure
321-
#figure.max_num_figures : 20 # The maximum number of figures to open through
322-
# the pyplot interface. If less than one,
323-
# there is no maximum.
321+
#figure.max_open_warning : 20 # The maximum number of figures to open through
322+
# the pyplot interface before emitting a warning.
323+
# If less than one this feature is disabled.
324324

325325
# The figure subplot parameters. All dimensions are a fraction of the
326326
# figure width or height

0 commit comments

Comments
 (0)