pweave module not generating figures

232 Views Asked by At

Having recently switched from R to Python, I am exploring Pweave as a substitute to Sweave. The example files (http://mpastell.com/pweave/examples/index.html) look great so I have started building on those. Using the command

pweave -f tex FIR_design_verb.texw

from the terminal generates a .tex file which can then be converted into a pdf with figures included.

Trying the same from the python interpreter (spyder in my case) as

import pweave pweave.weave('FIR_design_verb.texw', doctype = "tex")

does not yield the same result, the figures are not there. The tex file generated has

\begin{figure}[htpb] \center \caption{Test!} \label{fig:None} \end{figure}

lacking the \includegraphics{} and the figures folder is created but empty. Am I missing a parameter in pweave.weave()?

Ps: As a work-around, the following code works:

import subprocess cmd = ['pweave', '-f', 'tex', 'pweave_test.texw'] proc = subprocess.Popen(cmd) proc.communicate()

1

There are 1 best solutions below

0
On BEST ANSWER

I think the problem is that Spyder imports ˋmatplotlibˋ before Pweave so the figures are not captured. Your code should work if you run "plain" python interpreter.