|
From: <pl...@pi...> - 2015-12-13 15:30:02
|
Hi,
I need to plot a series of data files and one reference file.
here I get all the data files and one test plot
plot[0:1.2] for [ len=9000:7000:-50 ] s=0 \
, "data-".sprintf("%d",len).".out" u (1/$4):5 w l tit
sprintf("%d",len).".out" \
, "test_filter.out" u (1/$4):($5*1.5e08) w l tit " filter resp " \
but this way around I get the test plot n time and only the last data
file plotted.
plot[0:1.2] for [ len=9000:7000:-50 ] s=0 \
, "test_filter.out" u (1/$4):($5*1.5e08) w l tit " filter resp " \
, "data-".sprintf("%d",len).".out" u (1/$4):5 w l tit
sprintf("%d",len).".out" \
gnuplot> help for
The `plot`, `splot`, `set` and `unset` commands may optionally contain an
iteration for clause. This has the effect of executing the basic command
multiple times, each time re-evaluating any expressions that make use
of the
iteration control variable.
This does not seem consistent with what happens.
regards, Peter.
|
|
From: Juhász P. <pet...@gm...> - 2015-12-13 16:56:42
|
On Sun, 2015-12-13 at 15:14 +0000, pl...@pi... wrote:
> Hi,
>
>
> I need to plot a series of data files and one reference file.
>
>
> here I get all the data files and one test plot
>
> plot[0:1.2] for [ len=9000:7000:-50 ] s=0 \
> , "data-".sprintf("%d",len).".out" u (1/$4):5 w l tit
> sprintf("%d",len).".out" \
> , "test_filter.out" u (1/$4):($5*1.5e08) w l tit " filter resp " \
>
>
> but this way around I get the test plot n time and only the last data
> file plotted.
>
>
> plot[0:1.2] for [ len=9000:7000:-50 ] s=0 \
> , "test_filter.out" u (1/$4):($5*1.5e08) w l tit " filter resp " \
> , "data-".sprintf("%d",len).".out" u (1/$4):5 w l tit
> sprintf("%d",len).".out" \
>
The plot and splot commands accept a comma-separated list of functions
or datafiles (or variable assignments), and the for clause counts *per
function/datafile*.
So your command essentially sets s = 0 many times, then plots your two
datafiles once.
If you omit that s=0 from your first command (it seems to be superfluous
anyway), it will do what you want. You might want to reindent the
command to show that the for clause belongs to a specific datafile, not
the entire command:
plot[0:1.2] \
for [ len=9000:7000:-50 ] "data-".sprintf("%d",len).".out" u (1/$4):5 w
l tit sprintf("%d",len).".out", \
"test_filter.out" u (1/$4):($5*1.5e08) w l tit " filter resp "
>
>
> gnuplot> help for
>
> The `plot`, `splot`, `set` and `unset` commands may optionally contain an
> iteration for clause. This has the effect of executing the basic command
> multiple times, each time re-evaluating any expressions that make use
> of the
> iteration control variable.
>
>
This section does not mention the fact that the for clause affects just
one element of the plot list, however, the "help for loops" subtopic
does:
This will plot one curve, sin(3x), because iteration ends at the comma
plot for [i=1:3] j=i, sin(j*x)
This will plot three curves because there is no comma after the
definition of j
plot for [i=1:3] j=i sin(j*x)
>
> This does not seem consistent with what happens.
>
> regards, Peter.
>
>
>
>
Peter Juhasz
|
|
From: <pl...@pi...> - 2015-12-13 17:48:06
|
On 13/12/15 16:56, Juhász Péter wrote:
> On Sun, 2015-12-13 at 15:14 +0000, pl...@pi... wrote:
>> Hi,
>>
>>
>> I need to plot a series of data files and one reference file.
>>
>>
>> here I get all the data files and one test plot
>>
>> plot[0:1.2] for [ len=9000:7000:-50 ] s=0 \
>> , "data-".sprintf("%d",len).".out" u (1/$4):5 w l tit
>> sprintf("%d",len).".out" \
>> , "test_filter.out" u (1/$4):($5*1.5e08) w l tit " filter resp " \
>>
>>
>> but this way around I get the test plot n time and only the last data
>> file plotted.
>>
>>
>> plot[0:1.2] for [ len=9000:7000:-50 ] s=0 \
>> , "test_filter.out" u (1/$4):($5*1.5e08) w l tit " filter resp " \
>> , "data-".sprintf("%d",len).".out" u (1/$4):5 w l tit
>> sprintf("%d",len).".out" \
>>
>
> The plot and splot commands accept a comma-separated list of functions
> or datafiles (or variable assignments), and the for clause counts *per
> function/datafile*.
> So your command essentially sets s = 0 many times, then plots your two
> datafiles once.
No so , reread what I reported. In both cases I got multiple but
different plots.
>
> If you omit that s=0 from your first command (it seems to be superfluous
> anyway), it will do what you want. You might want to reindent the
> command to show that the for clause belongs to a specific datafile, not
> the entire command:
>
> plot[0:1.2] \
> for [ len=9000:7000:-50 ] "data-".sprintf("%d",len).".out" u (1/$4):5 w
> l tit sprintf("%d",len).".out", \
> "test_filter.out" u (1/$4):($5*1.5e08) w l tit " filter resp"
>
>
Firstly the s=0 syntactically superfluous but it's a trick I use make
all following lines have the same format ( beginning with a comma; end
in escape char ) , this means I can change line order or add/remove
lines without tiresome editing for syntax.
>>
>>
>> gnuplot> help for
>>
>> The `plot`, `splot`, `set` and `unset` commands may optionally contain an
>> iteration for clause. This has the effect of executing the basic command
>> multiple times, each time re-evaluating any expressions that make use
>> of the
>> iteration control variable.
>>
>>
>
> This section does not mention the fact that the for clause affects just
> one element of the plot list, however, the "help for loops" subtopic
> does:
Ah indeed:
"The scope of an iteration ends at the next comma or the end of the command,
whichever comes first. "
So this explains why the s=0 does not affect it. There is not yet any
substitution so there's not yet question of stopping at the " next" comma .
This does explain the difference in my two results which are then
consistent with the help description.
There probably should at least be a "see loops" . I did "more" until the
end of help on 'for' but since I had found the description of syntax I
was seeking, I did not go into the subtopics.
Many thanks for the reply, Peter.
>
>
> This will plot one curve, sin(3x), because iteration ends at the comma
> plot for [i=1:3] j=i, sin(j*x)
> This will plot three curves because there is no comma after the
> definition of j
> plot for [i=1:3] j=i sin(j*x)
>
>
>>
>> This does not seem consistent with what happens.
>>
>> regards, Peter.
>>
>>
>>
>>
>
> Peter Juhasz
>
>
>
>
|
|
From: <pl...@pi...> - 2015-12-14 11:33:18
|
On 13/12/15 16:56, Juhász Péter wrote:
>> plot[0:1.2] for [ len=9000:7000:-50 ] s=0 \
>> >, "test_filter.out" u (1/$4):($5*1.5e08) w l tit " filter resp " \
>> >, "data-".sprintf("%d",len).".out" u (1/$4):5 w l tit
>> >sprintf("%d",len).".out" \
>> >
> The plot and splot commands accept a comma-separated list of functions
> or datafiles (or variable assignments), and the for clause counts *per
> function/datafile*.
> So your command essentially sets s = 0 many times, then plots your two
> datafiles once.
Just for the record, since I pointed out that this was not correct and
contrary to what I had reported, it seems there was a fix between 5.0
and current cvs.
I have just installed the distro's 5.0 and indeed it does appear that
s=0 makes a difference and is possible with is getting done n times. I
only get the last data file plotted until I remove it. So Peter, you
seem to be right in the case of 5.0
What I said related to recent CVS gnuplot and was also accurate.
Thx.
|