-1

I have a GNUplot script in .gp file.

set terminal pngcairo enhanced size 5000,500 font 'DejaVuSerifCondensed,11' rounded; 
set output 'acc_vrecko_predne.png'
set encoding iso_8859_2

set yrange [-15:15]
set xrange [0:1261]
set xtics 20


set title 'dáta accelerometer - predne vrecko ' font 'DejaVuSerifCondensed-Bold,12'

set samples 7000

set style line 1  lt 1 lw 0.5 lc rgb "red"
set style line 2  lt 1 lw 0.5 lc rgb "blue"
set style line 3  lt 1 lw 1 lc rgb "green"


set datafile separator "|"


plot \
\
'data/vrecko_acc.txt' u 0:2 sm cs w l ls 1  t 'X-suradnice',\
'data/vrecko_acc.txt' u 0:3 sm cs w l ls 2  t 'Y-suradnice',\
'data/vrecko_acc.txt' u 0:4 sm cs w l ls 3  t 'Z-suradnice'

reset

Is there any way I can specify data path and filename in terminal and run script from it ? Should I change something in my .gpfile ?

THX

Mirko
  • 39
  • 2
  • 13
  • No need to ask a similar question again. Still, your question is answer in [How to pass command line argument to gnuplot?](http://stackoverflow.com/q/12328603/2604213). – Christoph Dec 03 '14 at 21:19

1 Answers1

0

It was a long time ago the last time I've used it. Any way, I guess it should be able to work fine with stdin-file, and you may do substitution on the fly by sed or normal shell variable subst like this:

$> x=uu; sort -u<<EOF
> a
> gg
> ${x}
> yy
> dd
> EOF
a 
dd
gg
uu
yy

if you put your gnuplot script in a shell script and will use 'Here Document' technique.

Make a file for example my_script.sh with a following content:

#!/bin/sh

file1="data/vrecko_acc.txt"
file2="data/vrecko_acc.txt"
file3="data/vrecko_acc.txt"
# or uncomment and use this variant to pass params as args like this:
#    sh my_script.sh data/acc1.txt data/acc2.txt data/acc3.txt 

# file1="${1}"
# file2="${2}"
# file3="${3}"

gnuplot - <<EOF
<here goes you file, do not forget to put '\'(back slash) before any $ sign>
'${file1}' u 0:2 sm cs w l ls 1  t 'X-suradnice',\
'${file2}' u 0:3 sm cs w l ls 2  t 'Y-suradnice',\
'${file3}' u 0:4 sm cs w l ls 3  t 'Z-suradnice'

reset
EOF
loshad vtapkah
  • 429
  • 4
  • 11