Reputation: 7922
I want to plot multiple bounded functions in gnuplot. I.e. plot x from 0 to 2 and x^2 from 1 to 3 and have them show up together.
How do you plot functions with different bounds?
I know how to do a piecewise function, like (x < 1 ? x : x**2). This is not what I want to do.
Upvotes: 4
Views: 6919
Reputation: 138357
plot 0 <= x && x <= 2 ? x : 1/0, \
1 <= x && x <= 3 ? x**2 : 1/0
We need to define what to draw outside the desired range, so we just use an undefined function f(x)=1/0
so that nothing is graphed in these ranges.
Upvotes: 6