I want to plot two functions in different ranges in Gnuplot. As an example, I want to plot f(x) for xrange [0:0.5] and g(x) for xrange [0.5:1], both in a same graph. What should I do for this?
-
using x2range is not helpful. Because this command moves the plot of x2range in x1range. So at the end, your plot is in xrange [0:0.5]. The thing that I want is having a plot range [0:1], and f(x) is the function in [0:0.5] range, and g(x) the function in [0.5:1] range.Reihaneh Kouhi– Reihaneh Kouhi2017-06-15 07:39:44 +00:00Commented Jun 15, 2017 at 7:39
Add a comment
|
1 Answer
You have at least two different solutions :
1) create a "heavyside" function :
f(x) = ... define your first function
g(x) = ... define your second function
h(x) = (x<0.5)?f(x):g(x)
plot h(x)
2) if you need some control on the color of each function, you could do
plot (x<0.5?f(x):1/0) lc 1, (x>0.5?g(x):1/0) lc 2