|
From: Thomas S. <t.s...@fz...> - 2010-12-09 09:51:15
|
gnuplot manual or 'help call' says: NOTE: there is a clash in syntax with the datafile using callback operator. Use $$n or column(n) to access column n from a datafile inside a called datafile plot. Beyer wrote: > > I have a data file where column one is the x-values. The second column is > a measure of current and the third is a measure of the potential drop > across a device. > I need to plot the conductance of the device which means I have to take > column 2 and divide it with column 3. > Something like plot 'bla.dat' u 1:($2/$3) > U = IR >> U/I = R >> I/U = 1/R = G > > Now I am making a multiplot since I am comparing five different graphs and > I am doing this by calling a script that works fine just plotting the > current alone, for example. The problem comes when I try to follow the > example given in "gnuplot in action" on page 41. > that says: "If an argument to using is enclosed in parentheses, it’s not > treated as a column number, but as an expression to be evaluated. Inside > the parentheses, > you can access the values of the column values for the current record by > preceding > the column number with a dollar sign ($) (as in shell or awk programming). > Some examples will help to clarify. > > ... > > To plot the average of the second and third columns, use > plot "data" using 1:( ($2+$3)/2 ) with lines" > > MY PROBLEM IS: > > CODESNIPPET FROM MY SCRIPT: > plot '$3.dat' u 1:($2/$3) w l ls 1 > > now the example in the book seems to indicate I have to use the dollar > sign in the parenthesis to indicate that I am talking about a column > number in the expression but when gnuplot reads the script it quite > naturally seems to read the two values as the fourth and third option fed > to the script when I call it from gnuplot. > This clearly isn't what I really want it to do, but I can't figure out how > I tell gnuplot that the $3 means "column three" not "script option 4" > ----------------- > I call the script by calling: > call 'multi.gp' 'firstmultitest' '3' '2' 'datafile' 'datafile2' > 'datafile3' 'datafile4' 'datafile5' > > The script as it appears now looks like: > #0=filename for the final graph 1=number of rows 2=number of columns > 3=data filename 4=data filename 5=data filename 6=data filename 7=data > filename 8=data filename > set terminal push > set output "$0.png" > set style line 1 lt -1 lw 2 > set terminal png size 1000,600 font Arial 16 > set multiplot layout $1,$2 > unset key > unset tics > set ytics 0,0.1 nomirror > set xtics -10,2.5 nomirror > unset border > set border 3 lt -1 lw 2 > plot '$3.dat' u 1:($2/$3) w l ls 1 > plot '$4.dat' u 1:(2/3) w l ls 1 > plot '$5.dat' u 1:(2/3) w l ls 1 > plot '$6.dat' u 1:(2/3) w l ls 1 > plot '$7.dat' u 1:(2/3) w l ls 1 > #plot '$8.dat' u 1:(3) w l ls 1 #not needed yet > unset multiplot > replot > set output > set terminal pop > > > Thank you very much for your help. > > -- View this message in context: http://old.nabble.com/The-use-of-%24-in-scripts-and-simple-data-transformations-in-scripts-tp30413982p30414485.html Sent from the Gnuplot - User mailing list archive at Nabble.com. |