Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to define a gnuplot output file as a variable?

Tags:

bash

gnuplot

In my bash file I have this declaration:

gnuplot -e "filename='Traffic1'" MyplotFile

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

I have these line on MyplotFile:

set output 'filename.png'

But the output is filename.png ! I want to have Traffic1.png as my output. How do I define this line correctly:

set output 'filename.png'

P.S. If you need to know about -e please go to this link

like image 939
alex Avatar asked Feb 13 '23 07:02

alex


1 Answers

With 'filename.png' you have simply defined a string. How should gnuplot know, that you mean a variable?

You can either concatenate your variable with the extension string

set output filename . '.png'

or you can use sprintf:

set output sprintf('%s.png', filename)
like image 119
Christoph Avatar answered Feb 20 '23 08:02

Christoph