Live data from Hacker News

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

github.com

41–50 of 68 posts

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

#42
post #32

I would suggest checking matplotlib2tikz and matlab2tikz to get pgfplot/tikz figures from matplotlib and matlab plots

Indeed, they're pretty cool (although in my experience the resulting TikZ code sometimes slows down compilation quite a bit).

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

#44

One itch which (curiously) I can't seem to quite scratch in LaTeX is that it should be possible to say "plot equation \ref{eq:smth} for X in (-4,4)" and just get the bloody graph. Why should I need to define the equation again in a separate place, perhaps even in a separate file?

[deleted]

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

#46

Any opinion on the utility of Emacs Org-mode to organize and manage LaTeX? In particular Org Babel?

I’ve written documents in org mode and converted to pdf via LaTeX, but I find that if the document gets sufficiently complicated with formatting, I have so many LaTeX blocks in my org file I might as well be writing LaTeX directly.

Maybe I’m doing something wrong. YMMV

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

#47
post #2

This is probably most useful for postgrad students getting started with writing with TeX. It’s worth pointing out that the figures are made using the matplotlib library, which is primarily based on Matlab’s plotting functionality. This is perhaps just as useful for new researchers as many of them are taught Matlab exclusively throughout their undergraduate courses.

It’s great for getting started, but if you start really customizing your plots the Object oriented usage of matplotlib is really the way to go.

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

#48

Earlier quoted context omitted.

Changing the plot backend should fix this. import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt https://stackoverflow.com/questions/2801882/generating-a-png...

I believe Agg is only for bitmap output. While there are probably backends that work with a headless system, I find the OO option much more flexible.

Agg works for all outputs. I use it in combination with OO over ssh all the time.

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

#49
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.

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

#50

Any opinion on the utility of Emacs Org-mode to organize and manage LaTeX? In particular Org Babel?

I’ve written documents in org mode and converted to pdf via LaTeX, but I find that if the document gets sufficiently complicated with formatting, I have so many LaTeX blocks in my org file I might as well be writing LaTeX directly. Maybe I’m doing something wrong. YMMV

That is true, but org-mode really shines when you want to do literate programming stuff, e.g. have the matplotlib code directly in the orgfile, ...
Post reply on HN