code: def export_graphics_to_svg(widget, filename):
      
      generator = QSvgGenerator()
      generator.setFileName(filename)
      generator.setSize(widget.size())
      generator.setViewBox(widget.rect())
  
      painter = QPainter()
      painter.begin(generator)
      widget.render(painter)
      painter.end()
docs: Export graphics to svg
  
      Parameters
      ----------
      widget : instance of QGraphicsView
          traces or overview
      filename : str
          path to save svg