[NTG-context] Pgfplots - passing point coordinates by Lua

Jaroslav Hajtmar hajtmar at gyza.cz
Mon Feb 17 01:11:44 CET 2014


Thanks Jorge
for the helpful and useful instructions. Sometimes it will certainly 
come in handy.

Jaroslav Hajtmar


Dne 17.2.2014 0:53, DesdeChaves napsal(a):
> \usemodule[tikz]
> \usemodule[pgfplots]
> \usemodule[pgfplotstable]
>
> \starttext
>
> \startluacode
>
> local dados={};
>
> for i=1,10 do
> dados[i]=2*i
> end
>
> context("\\starttikzpicture")
>     context("\\pgfplotsset{width=10cm, compat=1.3, legend 
> style={font=\\tfx}}")
>     context("\\startaxis[")
>     context("xlabel={L  (m) },")
>     context("ylabel={ $T^2 (s^2)$},legend cell align=left, legend 
> pos=north west]")
>     context("\\addplot[only marks] table[row sep=\\\\]{")
>      context("X Y\\\\")
> for key,value in pairs(dados) do
> context("%0.2f %0.1f \\\\", key, value)
> end
>  context("   };")
>     context("\\addlegendentry{Experimental points}")
>     context("\\addplot table[row sep=\\\\,")
>     context("y={create col/linear regression={y=Y}}]{")
>     context("X Y\\\\")
> for key,value in pairs(dados) do
> context("%0.2f %0.1f \\\\", key, value)
> end
>     context("};")
>     context("\\addlegendentry{")
> context("$\\pgfmathprintnumber{\\pgfplotstableregressiona} \\cdot x")
>         context("\\pgfmathprintnumber[print 
> sign]{\\pgfplotstableregressionb}$ lin. Regression}")
>     context("\\stopaxis")
> context("\\stoptikzpicture")
>
> \stopluacode
>
>
> \stoptext



More information about the ntg-context mailing list