I am new to gnuplot and I am troubled in passing my argument alot,
now I have this simple bash script and a gnuplot script.
in the bash script plot.sh
I should modify my file then send it to the gnuplot script to be plotted OR I can modify my file and just send a parameter (a number passed from another script $1) to the gnuplot script which identifies which file to be plotted, the problem is neither of the two ways is working, I don't seem to get it right! any help?
here's my bash script plot.sh
#!/bin/bash
sed -i 's/ns/;/g' /dev/shm/waitingTime$1.txt
gnuplot -e "filename='/dev/shm/waitingTime$1'" file.gnuplot
And here is my gnuplot script called file.gnuplot
#!/home/yas/file.gnuplot
set xlabel "start"
set ylabel "Delay"
set autoscale
set style line 1 lt 1 lw 3 pt 3 linecolor rgb "red"
plot<"filename"> using 1:2 w points title "tests"
set terminal postscript portrait enhanced mono dashed lw 1 'Helvetica' 14
set output '/dev/shm/TT.pdf'
pause -1
end of file.gnuplot
Best Answer
If I understand correctly, you want the graph to show up on the display and then have a copy in the PDF file
/dev/shm/TT.pdf
.I see two problems here:
The instruction for the plot --- you store the file name in
filename
, so ypu should just saywithout the
<"
... things.If you want the pdf file you should add a
replot
after the change of terminal and output file (double check you can write in the destination directory).I have created a file
data.dat
and the filefile.gnuplot
:And calling it with:
I have the output:
...and the corresponding
TT.pdf
file.By the way, instead of the
pause
at the end, I find much better to addat the start, and remove the pause. The script will finish naturally and the window with the graph will stay put until you dismiss it.