Thursday, September 18, 2014

Tip #2 [gnuplot]: Use of macros for repetitive commands

When you have a gnuplot script that uses the same command over and over again, use macros. The nice thing is that you can then modify the contents of the macro in the script, without having to change the macro.

Suppose you want to plot the columns 1 and 3 of three different data files.

In your gnuplot script include:

set macro
MACRO = "datafile using 1:3"

Then you can modify the value of datafile within the script

datafile="file1.txt"
plot @MACRO
pause(-1)


datafile="file2.txt"

plot @MACRO
pause(-1)


datafile="file3.txt"

plot @MACRO
pause(-1)

More extensive and complex examples of the usage of gnuplot macros can be found here.

No comments:

Post a Comment