What are the benefits of PGFPlots/TikZ compared to importing PDF?

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:

  1. I do not have to open several files and adjust things.
  2. If I include the graph in a beamer presentation, it automatically comes with the right font as the ambient document. If I understand you correctly, if I were to use the method you suggest I would have to produce a separate pdf for the beamer presentation.
  3. I also use some macros. Even though I do not use many of them, I find it sometimes convenient to define some symbols via a macro. I can use this macro also in my plots and figures.
  4. Even though this is not a major issue, when working on something together with others on a file just works. I do not have to worry that my collaborators may not have downloaded another plot from the repository. Rather, once they have the file, they have all they need to compile the document. Likewise, my collaborators can also add figures and plots in the same way without having to worry about these issues.

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.


Welcome to TeX.SE! I think there is not a default answer to your question per se. It more likely depends on the fact how you perceive TeX itself. If you merely view it as a system to format your text and structure your document, you are very likely to adopt the workflow to generate plots using your programming language than a system that it tightly integrated with TeX.

The viewpoint I, as a PhD student in signal processing, usually take instead is the following: I use TeX as a means of formatting and presenting my whole work and results in an appropriate fashion. This means that not only to I typeset my thoughts and arguments in TeX but also the simulation results and visualizations I can come up with.

That being said, I usually proceed the following way when it comes to plots:

  1. I write a whole bunch of simulation scripts that usually produce several MB of files containing some multidimensional simulation results and their parameters. These scripts tend to take very long computation wise and generate a whole bunch of data.
  2. I write an a lot smaller script that does the simulation data processing and this script produces two things. First it produces some very ugly plots, which only serve me as means of quickly debugging the data and the simulations in 1. And second at least one *.csv file, which usually only is a few KB only containing the data and parameters I actually want to plot. This can stem from averaging or applying some other kind of statistics to the data from 1.
  3. I use this *.csv file to generate plots using PGF by loading the data from it, which I can easily plug into a poster template, a beamer template or a paper template and a nicely composed selection of macros and color schemes make everything look very integrated with the rest of the document at hand.

What are the advantages of this approach you might ask and very rightfully so, since it seems to introduce one additional layer of complexity. The reasons for me doing this are in ascending order of importance

  1. It makes simulation data analysis more transparent, since it separates data generation from data evaluation.
  2. It makes my workflow more flexible, since the separation of simulation and evaluation allows one of the two to change without affecting the other. Especially when simulations take long, it is of tremendous value that the post-processing is decoupled from them.
  3. It forces me to think about the data structures within my simulation, which results in a more structured workflow itself.
  4. The decoupling of the post-processing (generating the *.csv-files) from the plotting yields again a more flexible workflow. After having generate all the data you need, you never ever have to touch it. It is just there and you can focus in TeX on the visualization.
  5. All data visualization parameters, so the parameters of your plots are at one place – in the TeX code – making it easier not to loose your mind.

Summarizing, it simply gives you more freedom, while also enforcing a more streamlined but structured workflow and puts things where they should be (IMHO), since programming is for data generation and TeX is amazing at making things look beautiful! :-)

EDIT: When collaborating with others it also is of tremendous value. If you only hand out raw or processed simulation results (which you can handle with git or any other similar tool quite nicely), you make it easier for others to modify the presentation of the data, since they do not need to run any code external to TeX to get things going.


The main reason is to match the text, as you already said, but also the arrow tips or other similar symbols.

Another reason (valid in my case) is "not to have another tool for plotting graphs available".

Another advantage is that all lines will have the same width. Graphs produced by external tools are often scaled during the inclusion in the document to fit them in the available textwidth or similar. This will change the width of their lines.