Restricting the domain of a function plotted on Gnuplot

后端 未结 2 1296
被撕碎了的回忆
被撕碎了的回忆 2020-12-30 05:48

I am plotting a set of data on Gnuplot, and want to superimpose the function x^2 on the same plot. I can do this like so:

plot \"filename\" usi         


        
2条回答
  •  死守一世寂寞
    2020-12-30 06:08

    The easiest way may be to define a piecewise function using the ternary operator ?:

    f(x) = (x > 1 && x < 2) ? x**2 : 1/0
    plot "filename" using 1:2, f(x)
    

    Another way is with the replot command:

    plot "filename" using 1:2
    replot [1:2] x**2
    

提交回复
热议问题