Hacker News new | ask | show | jobs
by sigurdjs 2650 days ago
If you are serious about making beautiful figures in latex, I would seriously recommend using tikz and pgf-plots. It is quite easy to automatically generate tikz-code from python (after all it is supposed to be read and written by humans) and all aspects of the figure can easily be customized. I have been quite successful in generating automated reports with pretty and easily readable figures using tikz and pgf.

If anyone is interested I have uploaded a sample script for generating XY-plots from two numpy lists to github. The code is by no means very good, but I just wanted to share in case anyone wants to try this approach.

https://github.com/sigurdjs/python-tikz

2 comments

And it's also possible to directly load a csv file with all the data in latex and plot if with pgf, which makes it possible to keep all the plotting options in the latex file:

  \addplot table[x ={Column1}, y ={Column2}] {myData.csv};
The issue is that it can take some time for pgf to load the data and do computations on them, but you can use the external library of tikz so that it does not compute the plot again (and save it as a pdf for later uses).
Indeed, TikZ is great to create beautiful-looking plots! A friend of mine is quite good at it, e.g. look at Figure 2 in [1] and Figure 2.1 (p. 18) in [2]. For complex figures, though, I find that TikZ can be a bit hard to master and sometimes results in longer compilation times.

[1] http://www.hrzn.ch/publications/tf-icnp15.pdf [2] http://www.hrzn.ch/publications/thesis.pdf