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

后端 未结 5 2148
别跟我提以往
别跟我提以往 2021-02-14 05:14

I know how to use $ with using in examples like

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

to plot functions of column data. But

相关标签:
5条回答
  • 2021-02-14 05:37

    Prepend an empty string if necessary. E.g.:

    gnuplot> a=42
    gnuplot> print a." questions"
             internal error : STRING operator applied to non-STRING type
    
    gnuplot> print "".a." questions"
    42 questions
    

    The first print fails because of a type mismatch. The second one works fine though. Apparently . is left associative.

    0 讨论(0)
  • 2021-02-14 05:38

    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)
    
    0 讨论(0)
  • 2021-02-14 05:38
    set title sprintf("Polinômio de Taylor no ponto %f ",a)
    

    or the English variant

    set title sprintf("Taylor Polynomial at the point %f ",a)
    

    will define the title transforming the number a into the previous string I have use this in a loop, with the Taylor Polynomial calculated previously at the point a, where a containing a number is the governing variable of the while.

    0 讨论(0)
  • 2021-02-14 05:43

    Are you looking for something like:

    plot for [c=1:5] datafile using (column(c)):(column(c+1))
    

    This will do: plot datafile u 1:2, "" u 2:3, "" u 3:4, "" u 4:5, "" u 5:6

    0 讨论(0)
  • 2021-02-14 05:45

    How about something like this? The loop statement could be different depending on the shell you are using. The one below is using bash.

    plot '< for i in 1 2 3 4 ; do echo $i ; done' us ($1):($1+1)
    
    0 讨论(0)
提交回复
热议问题