|
From: Stijn S. <sti...@ug...> - 2010-05-31 17:41:47
|
Hi,
I would like to use gnuplot to plot functions implicitly contained in a large
data table. However extracting the function tuple values, placing them in
columns and specifying the gnuplot plot commands is proving to be very tedious
work.
The table is made out of records containing various field. The same fields are
in the same column. Kind of like in a database. Each column has a symbolic
name. The table might then look something like:
x, y, f, g, u, s, t
record 1 | 1, 2, 3, 4, 5 0, 3
record 2 | ...
....
What I would like is a program or language in which I can state something
like:
"plot x : y : ( f + g * u ) (x,y) ", where f, g and u are functions of (x,y).
The program should then be able to form the proper gnuplot commands to plot
this.
Furthermore it would be nice if I could impose restrictions on the function
domains like "plot ( f + g * u ) (x,y) WHERE s==0".
Does anyone know of any software that can do this?
Thanks for reading
|
|
From: Thomas S. <t.s...@fz...> - 2010-06-03 18:37:25
|
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) Stijn Souffriau-3 wrote: > > Hi, > > I would like to use gnuplot to plot functions implicitly contained in a > large > data table. However extracting the function tuple values, placing them in > columns and specifying the gnuplot plot commands is proving to be very > tedious > work. > > The table is made out of records containing various field. The same fields > are > in the same column. Kind of like in a database. Each column has a symbolic > name. The table might then look something like: > x, y, f, g, u, s, t > record 1 | 1, 2, 3, 4, 5 0, 3 > record 2 | ... > .... > > What I would like is a program or language in which I can state something > like: > > "plot x : y : ( f + g * u ) (x,y) ", where f, g and u are functions of > (x,y). > > The program should then be able to form the proper gnuplot commands to > plot > this. > > Furthermore it would be nice if I could impose restrictions on the > function > domains like "plot ( f + g * u ) (x,y) WHERE s==0". > > Does anyone know of any software that can do this? > > Thanks for reading > > ------------------------------------------------------------------------------ > 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 > > -- View this message in context: http://old.nabble.com/function-data-extraction-tp28767807p28771388.html Sent from the Gnuplot - User mailing list archive at Nabble.com. |
|
From: Stijn S. <sti...@ug...> - 2010-06-04 16:59:11
|
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. |
|
From: Thomas S. <t.s...@fz...> - 2010-06-05 18:29:03
|
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 > > -- View this message in context: http://old.nabble.com/function-data-extraction-tp28767807p28791071.html Sent from the Gnuplot - User mailing list archive at Nabble.com. |
|
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 > |