I got a question very similar to this post (\includegraphics{\input{|shell command}}) which unfortunately hasn't been really answered.
The aim is to make a command that invokes a python script to make a plot figure, which is then inserted in LaTeX. What I have tried so far is the following:
main.tex:
\newcommand\pytexplot[1]{
\immediate\write18{python pytexplot.py #1}
\input{shellout}
}
\begin{document}
\includegraphic{\pytexplot{plot1}}
\includegraphic{\pytexplot{plot2}}
\end{document}
pytexplot.py is a python script that makes different plots depending on the provided parameter and saves a file shellout.tex containing the name and location of the image of the generated plot.
The error thus reported is an undefined control sequence (100+ in total), so I'm afraid this won't help much..
So far I figured it has to do with macro expansions, and tried putting in \expandafter at different positions but to no avail.
EDIT: wipet's 2nd suggestion seems to work, but it includes the same plot twice. Also, I don't know how to combine it with the shell command
Could someone help me out on this?
input{shellout}assumingshellout.texis the file congaing the desired plot. If that does not answer your question I'd suggest you compose a fully compilable MWE including\documentclassand the appropriate packages that sets up the problem. – Peter Grill Sep 27 '14 at 19:11\includegraphic, it is\includegraphics. AMWEstarting with\documentclasswould be better. – Sep 28 '14 at 10:07