How to define gnuplot output file as a variable?

In my bash file, I have this declaration:

gnuplot -e "filename='Traffic1'" MyplotFile

Now I want to pass Traffic1 or better say the value of the file name for the name of my output gnuplot file, which is in png format.

I have this line in MyplotFile:

set output 'filename.png'

But the output of filename.png ! I want to have Traffic1.png as my conclusion. How to correctly determine this line:

set output 'filename.png'

PS If you need to know about -e , follow the link

+4
source share
1 answer

With 'filename.png'you just defined a string. How does gnuplot know that you mean a variable?

set output filename . '.png'

sprintf:

set output sprintf('%s.png', filename)
+8

All Articles