Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gnuplot - smooth interpolation x=f(y)

I would like to plot a 2D graph with csplines interpolation of my data with an independent variable on y axis. The interpolating function should be in x = f(y) form. Is there any way to do this without switching axes?

gnuplot:

set terminal svg size 400,300 enhanced fname 'arial'  fsize 10 butt solid
set output 'out.svg'
set xrange [10:13]
plot "data.txt" using 2:1 notitle #smooth csplines

Data:

1 11.45294118
2 11.43529412
3 11.18823529
4 10.98235294
5 10.94117647
6 11.28823529
7 11.27058824
like image 337
user52610 Avatar asked Aug 27 '14 11:08

user52610


1 Answers

You can use a table as an intermediate file and do the interpolation in the usual way:

set table "data2.txt"
plot "data.txt" using 1:2 notitle smooth csplines
unset table
set xrange [10:13]
plot "data2.txt" using 2:1 w l notitle

enter image description here

If you want higher resolution you can use set samples before plotting to the table.

like image 72
Miguel Avatar answered Oct 14 '22 08:10

Miguel