What are the advantages and disadvantages of creating figures with the tikZ/pgfplots packages rather than directly with Matlab?

I'm using Matlab to get figures from data produced with Fortran calculations and I was wondering if it's better to produce them directly with Matlab (I use the .pdf format) or export them with Matlab2tikz and then process them with the tikZ/pgfplots packages directly on overleaf. Of course I need a very good graphical output and the overleaf compilation to be fast.


A solution that allows both perfect graphical output and fast compilation is to export your graph with Matlab2tikz, compile it separately in a standalone documentclass, like this:

\documentclass{standalone}
...
\begin{document}
\begin{tikzpicture}
...
\end{tikzpicture}
\end{document}

and then include the resulting .pdf in your main document with:

\includegraphics{mygraph.pdf}

You don't have to compile your main document twice for this, of course you have to compile the standalone document before.

As samcarter already said in their comment, the advantage of having TikZ is that you can have the same fonts as the rest of your document. So your document will look high-quality.

The disadvantage is that compilation time gets longer if you have a lot of TikZ pictures and compile them directly in your document.