Re: How to import the seaborn python library (based on matplotlib) in a RMarkdown report?
The seaborn python library is indeed using matplotlib. This library contains multiple backends that are not necessarily installed or configured. When loading seaborn, it will try to load the default backend based on TCL/TK (UI framework) which is bundled in the Tkinter python package.
You need to use matplotlib.use("Agg") (or any other properly configured backend) before importing seaborn in order to force matplotlib to use the correct backend. For information, the Agg backend only computes the plots without displaying them.
In notebooks, the magic first line %pylab inline will trigger this method in order to use a backend that sends the output as HTML to the notebook.