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
>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
[ 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<------------------------------------------------------------------------ ]