The following gnuplot code works good:
plot 'data.txt' using 2:4 ' %lf %lf %lf %lf' title "1 PE" with linespoints;
In the following code, I want to say: "Use the number from column 4, but then divide it by the number from column 3". Or: "Use the number from column 2, but divide it by the constant 2.0". The following code demonstrates what I try to achieve, but it does not work.
plot 'data.txt' using 2:4/4 ' %lf %lf %lf %lf' title "1 PE" with linespoints;
plot 'data.txt' using 2:4/2.0 ' %lf %lf %lf %lf' title "1 PE" with linespoints;
Is something like this possible?
Gnuplot uses two asterisks for exponentiation. Thus plot x**2+8*x+15 produces a quadratic with x-intercepts at -3 and -5. Gnuplot helpfully reminds one of what is being graphed in the upper right corner. Commands can be issued in a sequence to modify the graph appearance.
User-Defined FunctionsIf you can write an equation, gnuplot can calculate it. I mean, functions to be plotted are expressed in a simple functional form, for example, f(x)=a*x+b, and they do not contain a complicated integration / differentiation which needs a numerical calculation.
Running gnuplot is easy: from a command prompt on any system, type gnuplot. It is even possible to do this over a telnet or ssh connection, and preview the graphs in text mode! For best results, however, you should run gnuplot from within X Window, so that you can see better previews of your plots.
To run GNUPlot, you simply open a terminal, type “gnuplot” and hit enter. This will launch the software tool so you are ready to set your variables and start plotting.
I don't usually work with datafiles formatted like this, but I think you're looking for something like:
#divide column 4 by column 3
plot 'data.txt' using 2:($4/$3) ' %lf %lf %lf %lf' title "1 PE" with linespoints
#divide column 4 by constant 10.0
plot 'data.txt' using 2:($4/10.0) ' %lf %lf %lf %lf' title "1 PE" with linespoints
As a side note, I don't think there's any reason for passing the format portion to using here. Gnuplot splits the datafile on whitespace just fine:
plot 'data.txt' using 2:($4/$3) title "1 PE" with linespoints
Should work just fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With