|
From: sfeam <sf...@us...> - 2017-10-28 16:31:18
|
On Saturday, 28 October 2017 10:23:40 theozh wrote:
> Thanks a lot Ethan,
> I'll never would have found this one.
> With the minor change "ysum-$2/2", the following seems to place the
> number in the center of the portion.
>
> plot $Data u 2 ti col , '' u 3:key(1) ti col, \
> ysum=0 '' skip 1 using (0):((ysum = ysum + $2, ysum-$2/2)):2 with
> labels notitle, \
> ysum=0 '' skip 1 using (1):((ysum = ysum + $3, ysum-$3/2)):3 with
> labels notitle
>
> However, if looking at the syntax in "help plot"
> plot-element:
> {<iteration>}
> <definition> | {sampling-range} <function> | <data source>
> {axes <axes>} {<title-spec>}
> {with <style>}
>
> I still don't understand why and how ((ysum = ysum + $2, ysum-$2/2))
> works.
The comma is a mathematical binary operator indicating
serial evaluation. The operation
A,B
signifies "first evaluate A, then evaluate B, return the latter result"
https://en.wikipedia.org/wiki/Comma_operator
> So apparently, you can place an expression/function before the
> comma and the expression after the comma is actually plotted? Good to
> know, I didn't know that one can make such constructs. Would be nice to
> have an example in "plot help" or if you have a link where to find this
> documented, please let me know.
gnuplot> help expression operators binary
(4th from last in the long list of operators)
Serial evaluation occurs only in parentheses and is guaranteed to proceed
in left to right order. The value of the rightmost subexpression is returned.
For a demo the makes good use of this operator see
http://gnuplot.sourceforge.net/demo_cvs/running_avg.html
Ethan
|