2

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 Answers 2

4

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.

Sign up to request clarification or add additional context in comments.

2 Comments

I didn't know you could do this, originally I was afraid I'd have to write a script to generate the gnuplot script itself word-for-word. Even though I didn't use this for the project, this will come in handy in the future.
I think your link is broken
0

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))

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.