# Pass TeX macro to gnuplot environment - gnuplottex

I want to pass a TeX macro to the gnuplottex environment gnuplot. The example here is rather trivial but help solving would be appreciated. The end goal is to adapt the gnuplottex code to call octave instead and return a curve fit string in algebraic notation, via a text file, for use in a pstricks plot. Anyway although the example is trivial the solution would be helpful for non-trivial use.

\documentclass[]{article}
%
\usepackage[miktex]{gnuplottex}
%
\makeatletter
\def\plotme{\string 2*x}
\makeatother
%
\begin{document}
\pagestyle{empty}
\pagenumbering{arabic}
\begin{figure}
\begin{gnuplot}[terminal=postscript,terminaloptions=eps,scale=1]
plot [x=20000:20005] \plotme
\end{gnuplot}
\end{figure}
\end{document}

-

The callout to gnuplot happens in this line (line 141 in my gnuplottex.sty)

\immediate\write18{gnuplot \figname.gnuplot}


You would need to change that to call octave instead (and add commandline options accordingly. The \figname.gnuplot is written starting line 86

\def\gnuplotverbatimwrite#1{%


You would similarly need to adjust this to create octave commands. The inclusion of the finished figure happens in line 151

{\includegraphics[scale=\gnuplotscale]{\figname.\extension}}


You could change that to insert the output from octave into a pst-plot environment (which might be tricky), or change the file output from octave to contain all the code required to make the plot in a similar fashion to how the input file is written. You could then simply include this file.

Basically, you can execute arbitary shell commands and write arbitrary files. You have to find what works best for you, but it should certainly be possible.

-
Hi, Thanks for the response. I actually figured out how to do this with GNUplot rather than switching to octave. An example of some quick and dirty code is posted here: tug.org/pipermail/pstricks/2012/009491.html –  Buddy Feb 2 '12 at 19:17
I still don't know how to process tokens in the verbatim environment - I'm sure others will be able to figure it out. I just wanted to know if pstricks could use an external fitting backend and it appears it can - thanks again. –  Buddy Feb 2 '12 at 19:19