# The target of the first rule is the default goal. See:
# http://www.gnu.org/software/make/manual/html_node/Rules.html
-all: data-file.png data-stdin.png everything-stdin.png data-command.png
+all: data-file.png data-stdin.png data-file-descriptor.png \
+ everything-stdin.png data-command.png
# Generate an example data file
# For an explanation of $<, $@, and other special variables, see
data-stdin.png: data-stdin.gp sine.py
./sine.py | gnuplot "$<" > "$@"
+# No data filename required
+data-file-descriptor.png: data-file-descriptor.gp sine.data
+ gnuplot "$<" 4<sine.data > "$@"
+
# No data file required
everything-stdin.png: everything-stdin.gp sine.py
(cat "$<"; ./sine.py) | gnuplot > "$@"
--- /dev/null
+# Gnuplot (since v4.6.2) can read the script from a file and data from
+# an arbitrary file descriptor. This is useful when you want to plot
+# several data files with the same script, since you don't need to
+# hard-code the filename in the script itself.
+
+set term png
+set title 'Plotting data from a file descriptor'
+set xlabel 'x'
+set ylabel 'f(x)'
+
+# gnuplot> help special-filenames
+plot '<&4' t 'sin(x)'
+
+# the '<&4' syntax is reading from file descriptor 4. See `help
+# special-filenames` for details.
# gnuplot> help special-filenames
plot '< cat' t 'sin(x)'
-# the `cat` command is reading from stdin. There does not seem to be
-# a way to read from an arbitrary file descriptor without using the
-# '< COMMAND' syntax, although I just submitted a patch to add it:
-# https://sourceforge.net/tracker/?func=detail&aid=3600849&group_id=2055&atid=302055
+# the `cat` command is reading from stdin.