5

In a gnuplot instruction file, is it possible to indicate relative paths for the data source files and for the output? The paths must be relative to the gnuplot instruction file path.

Context I have large data files containing between 12 to 50 x-y curves that I process using PHP scripts and gnuplot in order to provide nice graphic views of the data. The views are generated using gnuplot and for each view, I have one .csv file, one gnuplot plotting instruction file and one graphic.

Everything is nicely sorted into folders. Usually, in a folder, the graphics are at the top level, then in a source/subfolder are the .csv and gnuplot files.

Sometimes, I need to slightly change the graphic. So I edit the gnuplot file, and I plot it again by calling gnuplot directly. Everything is fine, until I move the folders elsewhere. Which I do frequently.

2 Answers 2

3

Yes, you can specify relative paths in the gnuplot file:

set output '../path/to/outputs/output.eps'
plot '../path/to/csv/input.csv'

works fine. If you want to specify paths as arguments to the script, I recommend a bash wrapper:

#!/bin/bash

# argument 1 is path to input
# argument 2 is path to output

gnuplot << EOF
set terminal ...
set output '$2/output'

plot '$1/input1.csv', \
     '$1/input2.csv' ...
EOF
Sign up to request clarification or add additional context in comments.

3 Comments

Thank you. I tried, but it doesn't seem to work. I get : "Line 69: warning: Skipping unreadable file". I am using gnuplot 4.6, installed with macports on MAC OS 10.8.2. Is the path relative to the plot instruction file, or to the current directory in the shell ?
After testing it seems it is relative to the current selected directory in the shell.
Well, your message does not strictly answer my question. But, as the answer I seek appears to be: NO, your suggestion is the way to go. So it may help others.
2

I've stumbled onto using loadpath to get data loaded relative to one's $HOME:

set loadpath system('readlink -f ~/.gnuplot.scripts')

Of course, this is for un*x systems.

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.