Live data from Hacker News

Tips and tricks to write LaTeX papers in with figures generated in Python

github.com

61–68 of 68 posts

Re: Tips and tricks to write LaTeX papers in with figures generated in Python

#61

Is there a better and more comprehensive plotting library than Matplotlib, it's 3D plots a lack polish. Also it is kind of verbose and require much boilerplate. Its api is sprawling and hard to remember.

For 3D, I use https://en.wikipedia.org/wiki/MayaVi and its `tvtk` module and https://www.paraview.org/

It's API is not as sprawling but understanding the data classes takes some effort.

For 2D, matplotlib or ROOT fit my uses. But, if you think matplotlib is sprawling, you'll hate ROOT.

Re: Tips and tricks to write LaTeX papers in with figures generated in Python

#62
post #57

Is there a better and more comprehensive plotting library than Matplotlib, it's 3D plots a lack polish. Also it is kind of verbose and require much boilerplate. Its api is sprawling and hard to remember.

Check Seaborn, it may suit your needs. https://seaborn.pydata.org/

Also Plotly and Bokeh, although both are more targeted towards producing interactive web based plots rather than print ready plots.

Re: Tips and tricks to write LaTeX papers in with figures generated in Python

#63
A minor plug: I've found I generate graphs and tables in Jupyter notebooks, so I wrote ipynb-tex, to allow you to reference cells from a notebook directly in your LaTeX documents. This supports tables, and figures.

https://github.com/poulter7/ipynb-tex

Re: Tips and tricks to write LaTeX papers in with figures generated in Python

#64

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 a…

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

Re: Tips and tricks to write LaTeX papers in with figures generated in Python

#65
post #52

I already implement most of the points mentioned there. The most useful (and new) tip for me was however the rasterization part. I normally like to have pdf figures for my LaTeX papers, but last time I had some graphics with some thousands of points plotted, which were taking too long to be printed if you did that from windows (in Linux there was no problem, that's why I didn't catch the problem earlier). At the end…

Indeed, it's pretty useful to be able to rasterize only parts of the plot! Glad you find it useful!

Re: Tips and tricks to write LaTeX papers in with figures generated in Python

#66
post #59

Earlier quoted context omitted.

It is an extremely thin font which makes it unsuitable for screen reading.

A lot of the time, the TeX output target is paper, and there (with a decent resolution printer) it looks rather splendid (in my view anyway).

For me the horizontal line in the letter "e" often disappears with smaller text sizes.

Re: Tips and tricks to write LaTeX papers in with figures generated in Python

#67
post #37

I'd also add that for figures Inkscape is invaluable [1]. Save as svg once, and export it as whatever later. I typically export it to PDF (from within Inkscape) for pdflatex. While its typically indispensable for schematics, I often seem to run into the use case of combining previously generated plots or figures, or adding a label/text. Since Inkscape can import pngs, this is a breeze with it. I don't have to go back…

The problem with inkscape is that, any slight changes to the figures would make the user go deep into the workflow pipeline to make the changes. However using LaTeX packages like TikZ or PSTicks would simplify the workflow and make the document more maintainable.

I think this is one of those things that depend on your actual workflow, content etc. I see your point; for me this hasn't been a problem.
Post reply on HN