Search code examples
gnuplot

gnuplot setting line titles by variables


Iam trying to plot multiple data lines with their titles in the key based on the variable which I am using as the index:

plot for [i=0:10] 'filename' index i u 2:7 w lines lw 2 t ' = '/(0.5*i)

However, it cannot seem to do this for a fractional multiple of i. Is there a way around this other than to set the title for each line separately?


Solution

  • sprintf should provide all the functionality needed, e.g.,

    plot for [i=0:10] .... t sprintf(" = %.1f", 0.5*i)
    

    in order to use the value of 0.5*i with 1 decimal digit...