How to output smooth cspline curve as a data file

前端 未结 2 1299
长情又很酷
长情又很酷 2021-01-11 15:10

Does anybody know how to extract some data of smooth cspline curve for a given data?

For instance, there is a data file which has 2 columns corresponding to x and y

相关标签:
2条回答
  • 2021-01-11 15:48

    This can be done by setting a table. Consider the following data file:

    0 1
    1 2
    2 3
    3 2
    4 2
    5 4
    6 8
    7 5
    8 3
    9 1
    

    The data itself and its csplines interpolation look like this:

    enter image description here

    To print the interpolation to a table one does the following:

    set samples 100
    set table "table_100"
    plot "data" smooth csplines
    set samples 20
    set table "table_20"
    plot "data" smooth csplines
    unset table
    

    set samples determines the number of points used to construct the spline curve. And you can visualize it:

    set key left
    plot "data" pt 7 t "Original data", \
         "table_100" w l t "Splines (100 samples)", \
         "table_20" w l t "Splines (20 samples)"
    

    enter image description here

    0 讨论(0)
  • 2021-01-11 15:57

    Use set table 'temp.dat' to redirect the plotted data points to an external file

    set table 'temp.dat'
    plot 'myfile.dat' using 1:2 smooth cspline
    unset table
    

    To test it

    plot 'myfile.dat' using 1:2 with points title 'original points',\
         'temp.dat' using 1:2 with lines title 'smoothed curve'
    
    0 讨论(0)
提交回复
热议问题