docs: def fig_to_src(figure, image_format='png', dpi=80):
      """Convert a matplotlib figure to an inline HTML image.
  
      :param matplotlib.figure.Figure figure: Figure to display.
      :param str image_format: png (default) or svg
      :param int dpi: dots-per-inch for raster graphics.
      :rtype: str
      """
      if image_format == 'png':
          f = io.BytesIO()
          figure.savefig(f, format=image_format, dpi=dpi)
          f.seek(0)
          return png_to_src(f.read())
  
      elif image_format == 'svg':
          f = io.StringIO()
          figure.savefig(f, format=image_format, dpi=dpi)
          f.seek(0)
          return svg_to_src(f.read())