2
votes

I have a paired t file of values generated from my program, and the professor has given us a basic gnuplot script to work from. However, the title, output filename and input data file are all hard-coded in the script.

Is there any way to modify the variables inside the plot file?

for example, the current title is done via

set title "Voting"

and the plot command is executed via

plot 'data-confidence' using 14:3:9:12 notitle with errorbars, \
'data-confidence' using 14:3 notitle with points 2

Is it possible to do something like

gnuplot pairedt.g voting voting.data and have the script execute on the .data file?

2

2 Answers

4
votes

Convert the gnuplot script into a shell script that fills in the needed names by variable substitution. A nice way to do this is by using a here document.

A minimal example:

#!/bin/sh
    gnuplot << EOF
    set terminal postscript eps
    set output "$1.eps"
    plot "$1.dat"
EOF

This uses the first argument to the script to determine both the output file name and the name of the data file.

0
votes

It is a little unclear to me what you are exactly after but I think there are two possible ways for you to solve this "issue":

  1. Edit the gnuplot script so that is supports the way your data file looks. Or even better, write your own script that plots your data.

  2. Edit your program that generates the output file so that

    • the name of the output file is data-confidence,
    • the data file has the columns the gnuplot script needs (the columns are referenced with 14:3:9:12 (see here for the documentation))