What are the benefits of using tools like pgfplots
or tikz
directly in LaTeX compared to importing PDF/PGF generated by say matplotlib
?
This answer believed that the main reason is to match the plots with the rest of the document. It also mentioned that no other plotting packages from R
or python
can generate graphs that have the same high image quality as those generated by pgfplots
in LaTeX directly, but no examples or reasons were given. Is there evidence to back up this claim?
Another related question is that, is there any reason for exporting a plot to PGF instead of PDF? This comment said that the reason is PGF will generate the whole graph in LaTeX while importing to PDF even with usetex
will only use LaTeX for the text part of the graph. But if the main reason for plotting in LaTeX is that we can match the plots with the rest of the text document, usetex
exactly does that.
My current adopted approach to producing PDF documents with graphs is (i) generate graphs using tools like matplotlib
or other plotting packages in a scientific programming language so that I can do computations before plotting or plot repetitive graphs; (ii) export to PDF files and use usetex
if I want to match the font with my document; (iii) import the PDF files using \includegraphics
and make final adjustments.
This seems to work out just fine and I didn't notice any image quality issues or graph not matching with the rest of the document.
So are there any other reasons to use native plotting utilities like pgfplots
in LaTeX that I overlooked?
Best Answer
Welcome to TeX.SE! I think that, as long as you feel comfortable with the way you are producing and embedding the plots, and are happy with the result, this should be the way to go. I personally use TikZ and pgfplots for sufficiently simple plots (after I switched there from pstricks). My main motivation are points that are not in your list:
Having said this, let me also mention that there are sufficiently complicated plots which I do not do with pgfplots or TikZ. After all, LaTeX is not a computer algebra system.