Reihaneh Kouhi
Reihaneh Kouhi

Reputation: 559

Two different graphs in different ranges in the same plot at GNUPLOT

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?

Upvotes: 0

Views: 3508

Answers (1)

PinkFloyd
PinkFloyd

Reputation: 2183

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

Upvotes: 3

Related Questions