Reputation: 1
I've had a look at trying to plot some data with Gnuplot and super impose a function on it however I have found no information after a couple of hours research.
Say you have typical datapoints:
x y
0 1
1 5
2 6
3 6
...
and now you want to super impose a extrapolation taking y down to 0 for some gradient (eg. a gradient of 1 over 3 x steps, then your straight line function is (0 - 6)/(3)*x + 6 = -2*x + 6)
I am under the assumption you can just plot this via a parametric function,
eg:
y(x) = 2*x + 6
plot 'datafile.dat' using 1:2, \
y(x) [3:6]
Is this the right approach? I've tried but it doesn't plot correctly. Also my data is set xdata time and I'm doing a multiplot, (however I only need this on one of them) which complicates things. (I've also tried it with set parametric)
Any ideas?
Upvotes: 0
Views: 658
Reputation: 3765
you can generate a piece-wise function like this:
y(x) = (x>3 && x<6) ? 2*x + 6 : 0/1
plot [0:6] 'datafile.dat' using 1:2, y(x)
but it will draw a vertical line at x=3
.
the best attempt maybe to store the function in a file:
set table 'func.dat'
plot [3:6] y(x)
unset table
and then plot both data and function:
plot [0:6] 'datafile.dat' using 1:2, 'func.dat' w l
Upvotes: 0