Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Ethan A Merritt Newsgroups: comp.graphics.apps.gnuplot Subject: Re: difficult for loop synax :-| Date: Wed, 20 Aug 2014 17:50:52 -0700 Organization: made entirely of Lego Lines: 66 Message-ID: References: <9bc28e9e-f776-4407-8acc-f0bc7a964bcf@googlegroups.com> <7d92eab8-bceb-49bb-80aa-ff7834bc9a73@googlegroups.com> <9066cc28-d4c2-4bb6-a081-4ce966222a7e@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit Injection-Date: Thu, 21 Aug 2014 00:50:54 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="7bbfccb08e3cb0f92ebf95516f5f5a81"; logging-data="5280"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/CI3G/LcM7UXDuh5oC2Apg" User-Agent: KNode/4.11.4 Cancel-Lock: sha1:KOmYHvm73TRe4+5ZvlReH20Q3EU= Xref: csiph.com comp.graphics.apps.gnuplot:2558 Kalin Kozhuharov wrote: > Hello Ethan, > > Thank you for your time! I was trying to make self-contained example, > but because it was simple enough you "optimized" it ;-) "Premature > optimization is the root of all evil", said D. Knuth :-D > > On Thursday, August 21, 2014 2:15:51 AM UTC+9, Ethan A Merritt wrote: >>> Well, may be I oversimplified it, but the real thing is too complex >>> anyway. What about this: >>> >>> reset; f1(x) = (C=1.134324*x,0); f2(x) = sin(C*x); set xrange >>> [0:3.14]; plot a=f1(1), f2(x) title "n=1", a=f1(2), f2(x) title >>> "n=2" , a=f1(3), f2(x) title "n=3"; >> >> It is still not clear what you are aiming for. >> The sequence of commands above does not make sense. >> >> The function f1(x) is never plotted, so it plays no role except for >> its side effect of setting C to a constant. >> > Well, yes I'd have to admit I am using side-effects here. > And my code is turning to a small mess because I am trying to have > gnuplot do statistics in-line, instead of preprocessing the data. > > My current code is here: > https://github.com/thinrope/fixed_sensor_visualization/blob/master/timeplot_all.gpl#L26 > > plot for [ID in IDs] "tmp/" . ID . ".data" u 1:2 axes x1y2 w l lw 2 > title graph_title(ID); > > What I wanted to do is add another SMA filter on each datafile (or 2 > with different window) and still have it plot similar graph. > > so having defined SMA as in > https://github.com/thinrope/fixed_sensor_visualization/blob/master/timeplot.gpl#L46 > I was planning to write something along: > > plot for [ID in IDs] a=sma_24_init(0), "tmp/" . ID . ".data" u > 1:(sma_24($2)) axes x1y2 w l lw 2 title graph_title(ID); I think that statement would work if you just remove the unnecessary comma after the definition a=. Doesn't it? Ethan > IDs are list of numbers coming form the environment/Makefile, but can > be strings. > > May be possible with `set table` and `do for [ID in IDs]{init; plot;}` > but I'd rather avoid it. > > > Alternatively, something along > > init_OK=0; f3(x,n) = (init_OK ? a=f1(n): 0, f2(x)); > plot for [n=1:3] a=f3(x,n); > undefined variable: x > :-| > > Kalin.