How to convert an integer to a string in gnuplot

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.)

Best Answer

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)
Related Topic