Hi Lukas. A year ago, I tried something similar when I wanted to make an animated pdf images. With using Lua, I can not handle eventually, but for inspiration attach a piece of code that demonstrates how get into buffer some parameters without Lua code. Maybe it inspires you in your solution. I apologize for dirty code, but I cutting it from my old library and my context application. I did not clean it and I did not translate into English. For those interested I can possibly do. Jarda Hajtmar Here is my example: \usemodule[tikz] \usemodule[pgfplots] %\define[1]\ListEntry{#1\par} %\processcommalist[one,two,{three,four}]\ListEntry %\processseparatedlist[one*two*three,four][*]\ListEntry \def\zpracujparametry[#1]#2% {\processcommalist[#1]{\nastavparametr{#2}}} % Použití: % \zpracujparametry[1,5,3.7,4,5,8,9,11]{ % \getbuffer[funkce1] % \page % } \def\ZPRACUJPARAMETRY#1[#2]#3% {\processseparatedlist[#2][#1]{\nastavparametr{#3}}} % Použití: % \ZPRACUJPARAMETRY{znak separátoru}[1,5,3.7,4,5,8,9,11]{ % \getbuffer[funkce1] % \page % } \def\pmparametr#1=$#2${\global\def\parametr{#1}\global\def\mparametr{#2}} \def\nastavparametry#1#2{\pmparametr#2\global\def\pparametr{#2}#1}% \def\zpracujdvojparametry[#1]#2% {\processcommalist[#1]{\nastavparametry{#2}}} % Použití: % \zpracujdvojparametry[1=$a$,5=$b$,3.7=$c$,4=$d$,5=$e$,8=$f$,9=$g$,11=$h$]{ % \getbuffer[funkce1] % \page % } \def\ZPRACUJDVOJPARAMETRY#1[#2]#3% {\processseparatedlist[#2][#1]{\nastavparametry{#3}}} % Použití: % \ZPRACUJDVOJPARAMETRY{;}[1=$a$;5=$b$;3.7=$c$;4=$d$;5=$e$;8=$f$;9=$g$;11=$h$]{ % \getbuffer[funkce1] % \page % } \startbuffer[goniometrickefunkce] \def\function{cos(deg(\x+\parametr))} \def\permfunction{cos(deg(\x))} \def\permfunctiontwo{sin(deg(\x))} \startTEXpage \starttikzpicture[scale=1] \tikzset{style={font=\ssxx}} \startaxis [xmin=-1.6, xmax=10, domain=-1.6:10, ymin=-1.1, ymax=1.1, width=\textwidth, height=0.3\textwidth, axis x line=middle, axis y line=middle, axis equal=true, xlabel=$x$, ylabel=$y$, samples=600, clip=true, xtick={0}, ytick={-1,0,1}, grid=major, extra x ticks={-1.57,1.57,3.14,4.71,6.28,7.85,9.42,10.99,12.57}, extra x tick labels={$-\frac{\pi}{2}$,$\frac{\pi}{2}$,$\pi$,$3\!\frac{\pi}{2}$,$2\pi$,$5\!\frac{\pi}{2}$,$3\pi$}, title={{\framed[frame=off,height=1cm]{\blue $\ssb f\!:\ y=\cos{(x \mparametr )}$}}}, ] \addplot[color=yellow, line width=0.5pt] {\permfunctiontwo}; \addplot[color=red, line width=0.5pt] {\permfunction}; \addplot[color=blue, line width=1pt] {\function}; \stopaxis \stoptikzpicture \stopTEXpage \stopbuffer \starttext \ZPRACUJDVOJPARAMETRY{*}[1.57=$+\frac{\pi}{2}$*1.047=$+\frac{\pi}{3}$*0.785=$+\frac{\pi}{4}$*0.524=$+\frac{\pi}{6}$*0=$-0$*-0.524=$-\frac{\pi}{6}$*-0.785=$-\frac{\pi}{4}$*-1.047=$-\frac{\pi}{3}$*-1.57=$-\frac{\pi}{2}$*-3.142=$-\pi$*-4.712=$-\frac{3\pi}{2}$*6.28=$-2\pi$]{ \getbuffer[goniometrickefunkce] \page } \stoptext Dne 15.2.2014 20:38, Lukáš Procházka napsal(a):
Hello,
I just started experimenting with pgfplots package.
I'd have two questions:
1) When plotting/loading a data file: Is it possible to specify the comment mark, which is '#' and '%" by default? I'd need to treat ';' as a comment mark, too.
2) How to pass coordinates of plot points by Lua?
The following code:
---- \usemodule[tikz] \usemodule[pgfplots]
\startluacode data = {{5, 15}, {20, 20}, {24, -24}}
plot = function(data) local str
for i, v in ipairs(data) do str = (str or "") .. "(" .. v[1] .. "," .. v[2] .. ")" end
print("Crds=", str)
context(str) end \stopluacode
\starttext \starttikzpicture \startaxis[] \addplot[mark=none,color=red] coordinates {(11, 5) (12, 18)}; % THIS PLOT IS OK \addplot[mark=none,color=red] coordinates {\ctxlua{plot(data)}}; % THIS PLOT HAS NO POINT (?!) \stopaxis \stoptikzpicture \stoptext ----
gives error:
" ... fonts > fallback modern rm 12pt is loaded Crds= (5,15)(20,20)(24,-24) Package pgfplots: Error! Sorry, I could not read the plot coordinates near '(5,15)(20,20)(24,-24)'. Please check for format mistakes. ! Package pgfplots Warning: the current plot has no coordinates (or all have been filtered away)... "
Any idea from someone more familiar with pgfplots would be appreciated.
TIA.
Best regards,
Lukas
___________________________________________________________________________________ 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 ___________________________________________________________________________________