Search code examples
gnuplotsmoothing

Gnuplot x(y) smoothing


How do I smooth the data presented in the form x(y)? Gnuplot smoothing function of to invalid handles such cases.


As an example:

File(T-L.dat):

0.00    0.0
0.10    0.1
0.15    0.2
0.40    0.3
0.60    0.4
0.50    0.5
0.60    0.6
0.40    0.7
0.15    0.8
0.10    0.9
0.00    1.0

What I want.

Gnuplot session:

knkd@SCP71:~/MEAS/HEAT$ gnuplot

        G N U P L O T
        Version 4.6 patchlevel 4    last modified 2013-10-02 
        Build System: Linux x86_64

        Copyright (C) 1986-1993, 1998, 2004, 2007-2013
        Thomas Williams, Colin Kelley and many others

        gnuplot home:     http://www.gnuplot.info
        faq, bugs, etc:   type "help FAQ"
        immediate help:   type "help"  (plot window: hit 'h')

Terminal type set to 'wxt'
gnuplot> plot "T-L.dat" with lines

What I have.

Add smooth:

gnuplot> plot "T-L.dat" with lines smooth csplines

Result not good too (only 2 links, sorry).

Other features also not give the result that I wanted to. But really I need a spline.


Solution

  • Correct, gnuplot can smooth with splines only data of the form y(x). For this, the data is rendered monotonic in x before smoothing it. You data is symmetric with respect to y, this is why you get a straight line as result of the smoothing.

    In order to smooth your data with respect to y, you must first exchange the axes and save the result of the smoothing to a temporary file. This is then plotted with the correct axis selection:

    set table 'T-L-smoothed.dat'
    plot 'T-L.dat' using 2:1 smooth csplines
    unset table
    plot 'T-L-smoothed.dat' using 2:1 with lines, 'T-L.dat' with points pt 7
    

    enter image description here