5 examples of 'matplotlib close all figures' in Python

Every line of 'matplotlib close all figures' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
247def closeFigure(fig, ax, options, haveLabels=True, optOut=None):
248 if haveLabels and not options.nolegend:
249 if options.legendposition:
250 legend(loc=options.legendposition)
251 else:
252 legend()
253 applyPlotOptions(fig, ax, options)
254 if options.output or optOut is not None:
255 n = options.output
256 if optOut is not None:
257 n = optOut
258 for o in n.split(","):
259 savefig(o)
260 if not options.blind:
261 show()
262 fig.clf()
263 close()
264 gc.collect()
72def close(self):
73 if self.figure:
74 plt.close(self.figure)
75 self.figure = None
76 self.axes = None
23def close_figure(self, fig):
24 self.output += "closing figure\n"
621def close(fig=None):
622 """
623 Close a figure window.
624
625 Parameters
626 ----------
627 fig : None or int or str or `.Figure`
628 The figure to close. There are a number of ways to specify this:
629
630 - *None*: the current figure
631 - `.Figure`: the given `.Figure` instance
632 - ``int``: a figure number
633 - ``str``: a figure name
634 - 'all': all figures
635
636 """
637 if fig is None:
638 figManager = _pylab_helpers.Gcf.get_active()
639 if figManager is None:
640 return
641 else:
642 _pylab_helpers.Gcf.destroy(figManager.num)
643 elif fig == 'all':
644 _pylab_helpers.Gcf.destroy_all()
645 elif isinstance(fig, int):
646 _pylab_helpers.Gcf.destroy(fig)
647 elif hasattr(fig, 'int'):
648 # if we are dealing with a type UUID, we
649 # can use its integer representation
650 _pylab_helpers.Gcf.destroy(fig.int)
651 elif isinstance(fig, str):
652 allLabels = get_figlabels()
653 if fig in allLabels:
654 num = get_fignums()[allLabels.index(fig)]
655 _pylab_helpers.Gcf.destroy(num)
656 elif isinstance(fig, Figure):
657 _pylab_helpers.Gcf.destroy_fig(fig)
658 else:
659 raise TypeError("close() argument must be a Figure, an int, a string, "
660 "or None, not '%s'")
107def finalize(self):
108 self._pdf.close()
109 plt.close()

Related snippets