From: W. Trevor King Date: Fri, 22 Mar 2013 05:38:23 +0000 (-0400) Subject: data-file-descriptor.gp: Fead from a file descriptor with '<&n' X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=refs%2Fheads%2Fnote%2Fgnuplot;p=assignment-template.git data-file-descriptor.gp: Fead from a file descriptor with '<&n' My patch was accepted into 4.6.2 :). --- diff --git a/Makefile b/Makefile index fb6c7de..d971545 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,8 @@ # 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 @@ -19,6 +20,10 @@ data-file.png: data-file.gp sine.data 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 "$@" + # No data file required everything-stdin.png: everything-stdin.gp sine.py (cat "$<"; ./sine.py) | gnuplot > "$@" diff --git a/data-file-descriptor.gp b/data-file-descriptor.gp new file mode 100644 index 0000000..f9b9589 --- /dev/null +++ b/data-file-descriptor.gp @@ -0,0 +1,15 @@ +# 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. diff --git a/data-stdin.gp b/data-stdin.gp index d1d72a4..47436ef 100644 --- a/data-stdin.gp +++ b/data-stdin.gp @@ -8,7 +8,4 @@ set ylabel 'f(x)' # 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.