code: def paintEvent(self, event):
      self._update_dpi()
      dpi_ratio = self._dpi_ratio
      width = dpi_ratio * self.width()
      height = dpi_ratio * self.height()
      if (width, height) != self._renderer.get_canvas_width_height():
          surface = cairo.ImageSurface(
              cairo.FORMAT_ARGB32, width, height
          )
          self._renderer.set_ctx_from_surface(surface)
          self._renderer.set_width_height(width, height)
          self.figure.draw(self._renderer)
      buf = self._renderer.gc.ctx.get_target().get_data()
      qimage = QtGui.QImage(
          buf, width, height, QtGui.QImage.Format_ARGB32_Premultiplied
      )
      # Adjust the buf reference count to work around a memory leak bug in
      # QImage under PySide on Python 3.
      if QT_API == "PySide" and six.PY3:
          import ctypes
  
          ctypes.c_long.from_address(id(buf)).value = 1
      if hasattr(qimage, "setDevicePixelRatio"):
          # Not available on Qt4 or some older Qt5.
          qimage.setDevicePixelRatio(dpi_ratio)
      painter = QtGui.QPainter(self)
      painter.drawImage(0, 0, qimage)
      self._draw_rect_callback(painter)
      painter.end()
  
file_path: catboost/contrib/python/matplotlib/py2/matplotlib/backends/backend_qt5cairo.py
imports: import six
  from .backend_cairo import cairo, FigureCanvasCairo, RendererCairo
  from .backend_qt5 import QtCore, QtGui, _BackendQT5, FigureCanvasQT
  from .qt_compat import QT_API
label_desc: Use image node_id 3 for calling the FigureCanvasQTCairo obj's underlying member method code with example usage: obj.paintEvent(event) without return types