Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.graphics.apps.gnuplot > #2555
| Newsgroups | comp.graphics.apps.gnuplot |
|---|---|
| Date | 2014-08-19 23:15 -0700 |
| References | <9bc28e9e-f776-4407-8acc-f0bc7a964bcf@googlegroups.com> <lt0s51$jbh$1@dont-email.me> |
| Message-ID | <7d92eab8-bceb-49bb-80aa-ff7834bc9a73@googlegroups.com> (permalink) |
| Subject | Re: difficult for loop synax :-| |
| From | Kalin Kozhuharov <me.kalin@gmail.com> |
On Wednesday, August 20, 2014 10:03:27 AM UTC+9, Ethan A Merritt wrote:
> Kalin Kozhuharov wrote:
> > I have been trying to plot two dependent functions per single for
> > loop, but cannot get the syntax right...
> > This works but is a lot of typing and if I don't know the number of
> > arguments cannot be expressed:
>
> > plot C=1, sin(C*x) w l, C=2, sin(C*x) w l, C=3, sin(C*x) w l;
>
> Please clarify. I see only a single function there, evaluated
> three times. Where is the second dependent function?
>
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";
How can I turn it into something like:
N="1 2 3"; plot for [n in N] a=f1(n), f2(x) title "n=" . n;
so that it produces the same result (all plots on same graph, automatically linestyled) when I don't know N. Currently this produces only one graph when n=3, because the for loop is only evaluated till the ",", then f2(x) is plotted once. I need some kind of syntactic "brackets".
I also tried:
N="1 2 3"; do for [n in N] {plot a=f1(n), f2(x) title "n=" . n; pause .2; };
and saw how the plot is being generated, then overwritten by the next call of plot.
Cheers,
Kalin.
Back to comp.graphics.apps.gnuplot | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
difficult for loop synax :-| Kalin Kozhuharov <me.kalin@gmail.com> - 2014-08-19 11:57 -0700
Re: difficult for loop synax :-| Ethan A Merritt <EAMerritt@gmail.com> - 2014-08-19 18:03 -0700
Re: difficult for loop synax :-| Kalin Kozhuharov <me.kalin@gmail.com> - 2014-08-19 23:15 -0700
Re: difficult for loop synax :-| Ethan A Merritt <sfeam@users.sourceforge.net> - 2014-08-20 10:15 -0700
Re: difficult for loop synax :-| Kalin Kozhuharov <me.kalin@gmail.com> - 2014-08-20 11:50 -0700
Re: difficult for loop synax :-| Ethan A Merritt <EAMerritt@gmail.com> - 2014-08-20 17:50 -0700
Re: difficult for loop synax :-| Kalin Kozhuharov <me.kalin@gmail.com> - 2014-08-20 23:02 -0700
csiph-web