On 12-12-2011 22:39, Paul Menzel wrote:
Dear ConTeXt folks,
I have two coefficients saved in a text file
-0.157737135681261
-0.211443105668896
and I want to use them to plot a line with gnuplot.
Having several of those files I want to use Lua to create the formula
for the line for me.
I have not yet figured out how to read values from a file in Lua and
just tried to print a constant to the gnuplot command.
I tried the following.
\usemodule[gnuplot]
\startGNUPLOTscript[lua]
plot \ctxlua{context(1.2 * x + 3)}
\stopGNUPLOTscript
\startGNUPLOTscript[nolua]
plot 1.2 * x + 3
\stopGNUPLOTscript
\starttext
\useGNUPLOTgraphic[lua]
Above should be a plot.
\useGNUPLOTgraphic[nolua]
\blank
\CONTEXT\ \contextmark\ \contextversion
\stoptext
You have to twist your mide a bit:
\startluacode
local x = 10
context.startGNUPLOTscript{ "lua" }
context("plot %s",1.2 * x + 3)
context.stopGNUPLOTscript()
\stopluacode
\starttext
\useGNUPLOTgraphic[lua]
\stoptext
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
| www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the
Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________