|
From: Stijn S. <sti...@ug...> - 2010-06-05 19:12:48
|
That seems usable but pretty complicated. Maybe I should get to work on a more flexible script that, for any functional arithmetic expression, extracts the required columns from a datafile with named columns and generates the corresponding gnuplot command. Thanks! On Saturday 05 June 2010 08:28:55 pm Thomas wrote: > it's a little bit tricky, but it can be done using gnuplot only. the > following > script assumes a data file like in your 1st email: > > x, y, f, g, u, s, t > 1, 2, 3, 4, 5, 0, 3 > ... > > so here is the script: > > reset > > set datafile separator ',' > > # replace with your data file name: > dfn="ts.dat" > > # first some dummy plots the set the variables > set output > set terminal push > set terminal dumb > undefine x y f g u s t > > # determine the number of columns in the data file using the > # 1st line with numeric values, which is line 2 - we need > # numeric values because 'valid()' doesn't work with strings. > # (and plot something to avoid errors or warnings) > ncol=0 > plot for [i=1:100] dfn \ > using (valid(i)?ncol=ncol+1:0,i):(i) every ::1::1 > > # now find the position of each column name and store > # its position in the variable 'column name', assuming > # that the column names are in the 1st line of the data file > # (and plot something to avoid errors or warnings) > plot for [i=1:ncol] dfn \ > using (strstrt(stringcolumn(i)." ","x"." ")==1?x=i:0,i):(i) \ > every ::0::0 > plot for [i=1:ncol] dfn \ > using (strstrt(stringcolumn(i)." ","y"." ")==1?y=i:0,i):(i) \ > every ::0::0 > plot for [i=1:ncol] dfn \ > using (strstrt(stringcolumn(i)." ","f"." ")==1?f=i:0,i):(i) \ > every ::0::0 > plot for [i=1:ncol] dfn \ > using (strstrt(stringcolumn(i)." ","g"." ")==1?g=i:0,i):(i) \ > every ::0::0 > plot for [i=1:ncol] dfn \ > using (strstrt(stringcolumn(i)." ","u"." ")==1?u=i:0,i):(i) \ > every ::0::0 > plot for [i=1:ncol] dfn \ > using (strstrt(stringcolumn(i)." ","s"." ")==1?s=i:0,i):(i) \ > every ::0::0 > plot for [i=1:ncol] dfn \ > using (strstrt(stringcolumn(i)." ","t"." ")==1?t=i:0,i):(i) \ > every ::0::0 > show variables > > # and now do the plot > set terminal pop > > splot dfn \ > using (column(x)):(column(y)):(column(f)+column(g)*column(u)) \ > every ::1 > > Stijn Souffriau-3 wrote: > > On Thursday 03 June 2010 08:37:18 pm Thomas wrote: > >> the proper gnuplot command is: > >> > >> splot "yourdatafilename" using 1:2:($3+$4*$5) > >> > >> and plotting if s==0: > >> > >> splot "yourdatafilename" using 1:2:($6==0 ? $3+$4*$5 : 1/0) > > > > That's nice but I would like software that could work with named columns. > > This > > way I could state: > > ($time : $revenue - $cost) instead of having to know the actual column > > numbers. > > > > ------------------------------------------------------------------------- > >----- ThinkGeek and WIRED's GeekDad team up for the Ultimate > > GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the > > lucky parental unit. See the prize list and enter to win: > > http://p.sf.net/sfu/thinkgeek-promo > > _______________________________________________ > > gnuplot-info mailing list > > gnu...@li... > > https://lists.sourceforge.net/lists/listinfo/gnuplot-info > |