code: def savefig(writekey, dpi=None, ext=None):
      
      if dpi is None:
          # we need this as in notebooks, the internal figures are also influenced by 'savefig.dpi' this...
          if not isinstance(rcParams['savefig.dpi'], str) and rcParams['savefig.dpi'] < 150:
              if settings._low_resolution_warning:
                  logg.warn(
                      'You are using a low resolution (dpi<150) for saving figures.\n'
                      'Consider running `set_figure_params(dpi_save=...)`, which will '
                      'adjust `matplotlib.rcParams[\'savefig.dpi\']`')
                  settings._low_resolution_warning = False
          else:
              dpi = rcParams['savefig.dpi']
      if not os.path.exists(settings.figdir): os.makedirs(settings.figdir)
      if settings.figdir[-1] != '/': settings.figdir += '/'
      if ext is None: ext = settings.file_format_figs
      filename = settings.figdir + writekey + settings.plot_suffix + '.' + ext
      # output the following msg at warning level; it's really important for the user
      logg.msg('saving figure to file', filename, v=1)
      pl.savefig(filename, dpi=dpi, bbox_inches='tight')
docs: Save current figure to file.
  
      The `filename` is generated as follows:
  
          filename = settings.figdir + writekey + settings.plot_suffix + '.' + settings.file_format_figs