## plotting discontinuous functions

### plotting discontinuous functions

Greetings

I want to plot a function that is only defined on disjoint subsets of
the x-axis.  It is easy enough for me to write such functions on
paper, e.g.,

f(x)= 1 for [0,.5], [1.1,2], [2.3,4.1]
= undefined elsewhere

but it is not clear to me how to use gnuplot's syntax to plot the
function defined above.

Any help or suggestions would be appreciated.

Alec Himwich

### plotting discontinuous functions

> Greetings
> I want to plot a function that is only defined on disjoint subsets of
> the x-axis.  It is easy enough for me to write such functions on
> paper, e.g.,
> f(x)= 1 for [0,.5], [1.1,2], [2.3,4.1]
>     = undefined elsewhere

You need two main ingredients to be able to do this:

1) the "decision-making operator", which gnuplot inherited from C:

(x >=0 && x <= 0.5) ? one_value : other value

2) how to tell gnuplot a function's value is undefined:

undefined = 0/0

Using these two, you can define some convenience functions that help doing
this kind of thing:

inrange(x,a,b) = (x >= a && x <= b) ? 1 : undefined

f(x) = 1 * inrange(x, 0, .5) + 1 * inrange(x, 1.1, 2)  \
+ 1*inrange(x, 2.3, 4.1)
--

Even if all the snow were burnt, ashes would remain.

Hello,

I would like to plot an approximation of a function with piecewise
smooth splines.  This approximation can be discontinuous, so I would
like to have the possibility of drawing a discontinuous curve
consisting of small continuous pieces.  Is this possible with Gnuplot?
At the moment I'm using version 3.7, where I did not find anything
like that in the manual.

Thank you, Nicolas.