code: def _export_figure(self, filepath, data, format):
          
  
          formats = ["svg", "eps", "ps", "pdf", "png"]
          assert format in formats
  
          data = fig2x(data, format)
  
          try:
              outfile = open(filepath, "wb")
              outfile.write(data)
  
          except IOError, err:
              msg = _("The file {filepath} could not be fully written\n \n"
                      "Error message:\n{msg}")
              msg = msg.format(filepath=filepath, msg=err)
              short_msg = _('Error writing SVG file')
              self.main_window.interfaces.display_warning(msg, short_msg)
  
          finally:
              outfile.close()
docs: Export of single cell that contains a matplotlib figure
  
          Parameters
          ----------
          filepath: String
          \tPath of export file
          data: Matplotlib Figure
          \tMatplotlib figure that is eported
          format: String in ["png", "pdf", "ps", "eps", "svg"]