Search code examples
gnuplot

passing many .gp files to gnuplot vs. repeatedly passing one file


With gnuplot 5.2 patchlevel 6 and bash, in a folder with several .gp files which I create programmatically:

When I execute gnuplot *.gp gnuplot tells me Need full using spec for x time data for the 7th file and aborts.

When I execute ls *.gp | while read fn; do gnuplot $fn; done there's no error message and all plots are created.

The gnuplot command in question is

plot $TimesData using 3:xtic(1) title "{/*0.6 Title 1}" lc rgb "#0000E0",\
     $TimesData using 4 title "{/*0.6 Title 2}" lc rgb "#00A000"

Isn't the behaviour supposed to be identical? What am I missing?


Solution

  • The ways you are calling gnuplot are different, and can very well create different results.

    gnuplot *.gp starts a single gnuplot session in which all commands from the first file are executed, then from the second one and so on. Any settings that were changed by the first file are still different from default during the execution of the second file! Depending on what exactly is written in your script files, weird interference may occur.

    ls *.gp | while read fn; do gnuplot $fn; done iterates through all files and starts a new gnuplot session for each of the files, making all gnuplot calls independent from each other.

    Therefore your second approach is the correct solution to your problem, although you could try to put reset session at the first line of each script file, run gnuplot *.gp and see what happens.