In my experience adding matplotlib figures into Latex documents is not trivial
at all, unless you are satisfied with a simple non-vector png. I will try to
explain here how to export a figure into pgf, and how to include that in
your tex file later. The usual disclamer is valid here: it works on my
machine and I can’t guarantee that it will work on yours. As of now, I am using
python 3.9 and
matplotlib 3.4. After the tutorial you can expect some
result as the one shown in the figure below.