class_docstr: An Htmlbook is used to generate an html page from text and matplotlib figures.
class_docstr_tok: ["An","Htmlbook","is","used","to","generate","an","html","page","from","text","and","matplotlib","figures","."]
docstr: Adds a matplotlib figure embedded directly into the html.
docstr_tok: ["Adds","a","matplotlib","figure","embedded","directly","into","the","html","."]
code: def add_plot(self, matplotlib_figure, ext="svg", **kwargs):
      """Adds a matplotlib figure embedded directly into the html."""
      out = BytesIO()
      matplotlib_figure.savefig(
          out, format=ext, bbox_inches="tight", **kwargs
      )
      plt.close(matplotlib_figure)
      if ext == "svg":
          self.doc.asis(
              "<svg" + out.getvalue().decode().split("<svg")[1]
          )
      else:
          out = base64.b64encode(out.getbuffer()).decode("ascii")
          self.doc.asis(
              "<img src='data:image/{};base64,{}'/>".format(ext, out)
          )
      self.doc.stag("br")
  
file_path: pycls/pycls/sweep/htmlbook.py
imports: import base64
  from io import BytesIO
  import matplotlib.pyplot
  from yattag import Doc, indent
label_desc: Use image node_id 3 for calling the Htmlbook obj's underlying member method code with example usage: obj.add_plot(matplotlib_figure, ext) without return types