Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I convert an integer to a string in gnuplot?

Tags:

gnuplot

I know how to use $ with using in examples like

plot datafile using f($1):g($2)

to plot functions of column data. But I want to use this feature in a loop:

plot for [c=1:10] datafile using f($(c)):g($(c+1))

Of course this code doesn't work. I guess that if I know how to convert the integer c to a string (or a single ASCII character) then it would work. How can I do it?

(If the same task can be done without conversion of integer to string, that would be fine too.)

like image 619
Mahdiyar Avatar asked Mar 09 '11 06:03

Mahdiyar


1 Answers

You can Use intrinsic function sprintf to convert numbers to string

gnuplot>  a=3; b=6;
gnuplot>  plot a*x+b title sprintf("a=%1.2f; b=%1.2f",a,b)
like image 88
Sergei Avatar answered Sep 29 '22 12:09

Sergei