Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

plotting function over limited range

946 views
Skip to first unread message

Erik Luijten

unread,
Apr 29, 1997, 3:00:00 AM4/29/97
to


Hi!

I wonder if anyone could help me with the following (if it is possible
at all). I have a set of experimental data I want to plot in a graph.
In a limited range these data are described by some function. Now, if I
define some function in gnuplot and plot it along with the data, this
function is plotted over the full width of the graph, which I is not what
I want. I considered defining the function only over the limited range
by using ternary operators, like

f(x) = (x<1? 0:(x**2))

(supposing that 0 lies outside the yrange).
However then you see a line coming from y=0 to y=1 at x=1, which is not
desirable of course. So I simply would like something like

f(x) = x**2
set xrange [0:10]
plot "datafile", [1:10] f(x)

How do I realize this?

Many thanks for your help,

Erik Luijten

--
Erik Luijten | Theoretical Physics Group
er...@tntnhb3.tn.tudelft.nl | Department of Physics
er...@ising.tn.tudelft.nl | Delft University of Technology
tel. +31-15-2786156 | Lorentzweg 1
fax +31-15-2781203 | 2628 CJ Delft --- The Netherlands
Homepage: http://www.tn.tudelft.nl/tn/erik.html

Bjoern Lorenz

unread,
Apr 29, 1997, 3:00:00 AM4/29/97
to

On 29 Apr 1997 13:49:07 +0100, er...@tntnhb3.tn.tudelft.nl (Erik Luijten)
wrote:

>I want. I considered defining the function only over the limited range
>by using ternary operators, like
>
>f(x) = (x<1? 0:(x**2))
>
>(supposing that 0 lies outside the yrange).
>However then you see a line coming from y=0 to y=1 at x=1, which is not
>desirable of course. So I simply would like something like
>
>f(x) = x**2
>set xrange [0:10]
>plot "datafile", [1:10] f(x)
>
>How do I realize this?

f(x) = ( x<1 ? x/0 :(x**2) )

see somewhere in the manual, I've forgotten where.

--
Dipl.-Ing. Bj"orn Lorenz
Klinik fuer Anaesthesiologie und Intensivtherapie
Universitaetsklinikum Charite
lor...@rz.charite.hu-berlin.de ________________________________ D-10098 Berlin

Bjoern Lorenz

unread,
Apr 29, 1997, 3:00:00 AM4/29/97
to

For the sake of completeness, it was in the description of the ternary
operator:

[ 8<------------------------------------------------------------------------ ]

Plot a function that is to equal sin(x) for 0 <= x < 1, 1/x for 1 <= x < 2,
and undefined elsewhere:
f(x) = 0<=x && x<1 ? sin(x) : 1<=x && x<2 ? 1/x : 1/0
plot f(x)
Note that gnuplot quietly ignores undefined values, so the final branch of the
function (1/0) will produce no plottable points. Note also that f(x) will be
plotted as a continuous function across the discontinuity if a line style is
used. To plot it discontinuously, create separate functions for the two
pieces. (Parametric functions are also useful for this purpose.)

[ 8<------------------------------------------------------------------------ ]

0 new messages