|
From: Jon <dev...@gm...> - 2011-02-16 00:41:42
|
Dear Tait, I guess the script you analyzed is what I wrote, but not by Nunzio Losacco. His code is a bit complex than mine. What I am asking is basically the concept of one pass or two passes possibly used by gnuplot, similar concept relevant to SAS or database languages. Sincerely, Jon On Tue, Feb 15, 2011 at 5:29 PM, Tait <gnu...@t4...> wrote: > > (Sorry this was delayed; I accidentally sent from the wrong address > and it was rejected by the moderator. But having already written it, > it seemed a shame not to send it.) > > > set term dumb > > min=10**10 > > plot 'disy.100' u ($3<min?min=$3:min=min,$1):3 > > > > set term x11 > > plot 'disy.100' u 1:($3/min) > > > > and you easily see the idea I wrote it this way. I think this reflects a > big > > problem for me to understand deeply how gnuplot deals with datafile and > how > > it plots, which is obviously different from the standard programming > > languages. Thanks for your in-depth explanation or references, > > > First, are you familiar with C? The syntax is similar, and it is described > in "help ternary". The ternary operator: > (condition) ? true-expr : false-expr > is a single-line if/then/else construct. If condition is true, then > true-expr is evaluated. Otherwise, false-expr is evaluated instead. So > consider: > $3<min ? min=$3 : min=min > If the third column is less than the value of the variable min, then > assign this new value to min. Otherwise do a non-operation (of setting > min equal to itself). > > The "plot... using ($3<min?min=$3:min=min,$1):3" means plot the third > column as the y-coordinate, against the stuff in parenthesis as the > x-coordinate. In recent gnuplot versions, multiple expressions can > be evaluated for each line of the input file, by separating them with > a comma. The stuff in parenthesis finds the minimum value of column 3 > (and saves in it variable min), then evaluates $1, which just means the > value of column 1. > > The first plot is output as text in the console, so you might not have > seen it. It doesn't matter, because it's just a throwaway plot used to > find the minimum value of column 3 anyway. > > The second plot is the one that matters. It plots your data file using > 1:($3/min) which means plot column 3 divided* by min versus column 1. > > Another approach to this problem would be to use an external program/script > to find the minimum value of column three. I often use Perl for these > tasks. Others use sed/awk/shell scripts. We should probably develop some > C programs for contrib to do common tasks like this. For example: > filename="disy.100" > c3min = `min_value_by_col.pl filename 3` > set term X11 > plot filename using 1:(($3+0.0)/c3min) > > > > > * The division here is possibly integer division, depending on the values > from column 3 of 'disy.100'. If you want to assure floating-point results > from the division, you should instead: > plot 'disy.100' using 1:((0.0+$3)/min) > or something similar. Adding 0.0 will force promotion of $3 to a float > type, which will in turn force the division to be a floating-point > operation. > > > > ------------------------------------------------------------------------------ > The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE: > Pinpoint memory and threading errors before they happen. > Find and fix more than 250 security defects in the development cycle. > Locate bottlenecks in serial and parallel code that limit performance. > http://p.sf.net/sfu/intel-dev2devfeb > _______________________________________________ > gnuplot-info mailing list > gnu...@li... > https://lists.sourceforge.net/lists/listinfo/gnuplot-info > |