I am new to gnuplot and i am trying to determine the mina nd max from a datafile and afterwards plot the data
So far I have managed to determine the min and max like this:
# Define two helper functions
ismin(x) = (x<min)?min=x:0
ismax(x) = (x>max)?max=x:0
# Initialise the 'global' vars
max=-1e38
min=1e38
plot "Data.txt" u 0:(ismin($3)*ismax($3))
The problem is that I am trying to plot the data using splot, and it's not working.
I am trying this:
splot \
'Data.txt' u 2:1:3 with pm3d t '',\
If I remove the part related to determining the min and max, the splot command works.
Any suggestions?
Gnuplot is a free, command-driven, interactive, function and data plotting program. Pre-compiled executeables and source code for Gnuplot 4.2. 4 may be downloaded for OS X, Windows, OS2, DOS, and Linux. The enhancements provided by version 4.2 are described here.
splot is the command for drawing 3-d plots (well, actually projections on a 2-d surface, but you knew that). It can create a plot from functions or a data file in a manner very similar to the plot command. See plot (p. ) for features common to the plot (p. ) command; only differences are discussed in detail here.
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.
Look into the stats command:
stats 'datafile' using 3
for example, will get statistics on the 3rd column (z data), and store them in variables (STATS_min and STATS_max may be what you want). To see all the variables created, type
show variables all
after running stats. If you have an older version of gnuplot without stats, you can plot the file without creating an output, and gnuplot automatically defines some DATA_-prefixed variables including a min/max. The stats command saves the trouble of defining a null output to get data before plotting.
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