class_docstr: Class to execute plotting files, and extract the mpl and mpld3 figures.
class_docstr_tok: ["Class","to","execute","plotting","files",",","and","extract","the","mpl","and","mpld3","figures","."]
docstr: Execute the file, catching matplotlib figures
docstr_tok: ["Execute","the","file",",","catching","matplotlib","figures"]
code: def execute_file(self):
      """
      Execute the file, catching matplotlib figures
      """
      dirname, fname = os.path.split(self.filename)
      print("plotting {0}".format(fname))
  
      # close any currently open figures
      plt.close("all")
  
      # close any currently open figures
      plt.close("all")
  
      with mpld3_noshow() as mpld3:
          with use_dir(dirname):
              try:
                  # execute file, forcing __name__ == '__main__'
                  exec(
                      open(os.path.basename(self.filename)).read(),
                      {
                          "plt": plt,
                          "mpld3": mpld3,
                          "__name__": "__main__",
                      },
                  )
                  gcf = matplotlib._pylab_helpers.Gcf
                  fig_mgr_list = gcf.get_all_fig_managers()
                  self.figlist = sorted(
                      [
                          manager.canvas.figure
                          for manager in fig_mgr_list
                      ],
                      key=lambda fig: fig.number,
                  )
              except:
                  print(80 * "_")
                  print("{0} is not compiling:".format(fname))
                  traceback.print_exc()
                  print(80 * "_")
              finally:
                  ncol = gc.collect()
  
imports: import os
  import glob
  import sys
  import gc
  import traceback
  import itertools
  import json
  import contextlib
  import matplotlib
  import matplotlib.pyplot
  import mpld3
  from mpld3 import urls
  from mpld3._display import NumpyEncoder
  from mpld3.mpld3renderer import MPLD3Renderer
  from mpld3.mplexporter import Exporter
label_desc: Use image node_id 2 for calling the ExecFile obj's underlying member method code with example usage: obj.execute_file() without return types