Lately, I'm more involved with Python development (as being a member of the dev team for SciPy, writing packages for Python etc.) and I have been using TikZ
based tools for over a decade now I can offer my own perspective.
First of anything, you cannot do serious numerical computations with TeX
. You can do, to some extent, with pgfplots
with its internal fpu
format which tries to be IEEE-compliant as much as it can. But still, it is not at a production-ready state. Given that it is maintained by a single person, I think that is already incredible to have a plot patch and you can get a surface plot within TeX
. Also, the amount of data you can squeeze in for a single PDF page in terms of resources doesn't even come close to satisfactory for today's standards. The visualizations you have mentioned often originate from massive datasets and very sophisticated computations for which TeX
allows none. Besides, every day a new interactive tool emerge and I am a huge fan of bokeh
package in Python. If I'm not typesetting anything that is my go-to tool these days.
This has been discussed multiple times on this site but as a summary: TeX
is old, obscure, and orphaned. If compared to contemporary tools such as Python or R, there is nothing good left in its arsenal in terms of programming convenience. Mostly it is a collection of annoying token collection and expansion.
And this is perfectly fine because it is set to do one single thing: typesetting pages. And it does it amazingly, there is no contest, it is still the best. But in my opinion, this should be the fault of others instead of the success of TeX
. Because it is really a shame of other parties especially academia being the major consumer of TeX
for not placing TeX
on a professional "modern" foothold and hence cutting its ties to all advances in programming languages.
Then why would you bother using pgfplots
? The main reason is linked to the above discussion. TeX
is the game in town when it comes to typesetting and an integrated plotting tool is essential to have matching graphics. I'm skipping the argument why it looks ridiculously bad if you copy/paste from other sources which is the very reason why these tools exist. Back in the day, PSfrag
was attempting a similar thing by just replacing the text parts via its TeX-typeset version within EPS images. But that wasn't sufficiently successful. With tools like TikZ
and pgfplots
you have an extremely convenient API to PostScript
objects to insert vector graphics. But let me emphasize, this is only to generate visualizations that match the rest of the document. These packages are not meant for generic-use graphic software. In fact, TikZ
recursion is actually based on this fact.
"TikZ ist kein Zeichenprogram"
(German for: TikZ is not a software for drawing.)
These tools are meant for visually stunning document typesetting. And if the data you have, is within the capabilities of pgfplots
none of those packages in R or Python would match the image quality that you would get from pgfplots
. I have typeset my thesis with TikZ
and pgfplots
which have images with carefully downsampled data just to be able to use these tools and the results are amazing. But I was using pythontex
to reach out to my Python script and do the heavy lifting there and using those results. Instead of typing 195 lines in matplotlib
and getting a mediocre line plot, I do 10 lines of pgfplots
and I get a great result in terms of visual quality.
For more powerful graphics, we also have PSTricks
, Asymptote
, METAPOST
but they don't come with the convenience of TikZ
API which is unfortunate. One can only hope.
pgfplots
and if you want correct and efficient computation results use an external tool. It's a question of taste and aims.pgfplots
's only benefit is that I can make a document where the plot is made in situ? Since you pretty much always need separate figure files anyway, that seems to me like a very-very marginal use case.pgfplots
andmatplotlib
are eqaully valid choices for data-visualization. On rare occations I did usepgfplots
to construct graphs datapoint by datapoint manually. For visualizing actually gathered data I would never ever usepgfplots
. I used to usegnuplot
for this task, just because it was the first tool I ever used for this and it never let me down ... as long as there are only a few datapoints.gnuplot
is nice, but I think it is ugly and it is also a separate program. I sometimes use it for quick and dirty plots of datafiles but never for anything serious. But anyhow, you are saying that you would not really use it to plot data. Then what would you usepgfplots
for?gnuplot
output, either so I adopted a hybrid approach. By using thesagetex
package you get a CAS plus Python for accurate calculations which are then given topgfplots
to make it look better. See, for example, my answer here in plotting the prime function or here for drawing the Dragon's curve fractal.