0

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?

1
  • 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. Commented Jun 15, 2017 at 7:39

1 Answer 1

3

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.