code: def get_unique_figname(dirname, root, ext):
      
      i = 1
      figname = root + '_%d' % i + ext
      while True:
          if osp.exists(osp.join(dirname, figname)):
              i += 1
              figname = root + '_%d' % i + ext
          else:
              return osp.join(dirname, figname)
docs: Append a number to "root" to form a filename that does not already exist
      in "dirname".