2

I’d like to plot some function f(x) where f(x) = x for 0 ≤ xa, and −2 otherwise. And I’d like to plot it on a graph with x axes between two arbitrary points.

How would I go about doing this with Gnuplot?

2 Answers 2

2

This is straight out of the gnuplot documentation ("help ternary"):

f(x) = (x>=0 && x <=a)?x:-2

After setting a value for a, you will be able to plot this function over any range you want.

1

Try something like:

set xrange [ -4 : 4 ]

or

plot [ -4 : 4 ] f(x)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .