Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gnuplot: Plotting a path over a surface

Tags:

gnuplot

I want to plot a path over a 3d surface in gnuplot, but I can't figure out how to do it. The 3d surface is generated by a function, which I can display with a contour plot, and the path is a series of data points [x, y, f(x,y)] which I can display with lines palette (so the value of f(x,y) changes the color of the line. But is there a way to overlay the line on the contour plot? I can't manage to make it work. Thanks in advance.

like image 296
user1535823 Avatar asked Apr 11 '26 04:04

user1535823


1 Answers

It should be pretty simple... Here's a little example script with datafile:

datafile (test.dat):

.1 .1
.2 .2
.3 .3
.4 .4
.5 .5
.6 .6

plotting script:

set yrange [0:1]
set xrange [0:1]
f(x,y) = sin(x*10)*cos(y*10)
splot f(x,y),'test.dat' u 1:2:(f($1,$2)) w lines

If you want to color your line segments according to a palette:

splot f(x,y),'test.dat' u 1:2:(f($1,$2)):(f($1,$2)) w lines palette
like image 154
mgilson Avatar answered Apr 16 '26 13:04

mgilson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!