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

functions with different xranges

1 view
Skip to first unread message

Daniel Winkelmann

unread,
Feb 16, 2004, 1:52:19 PM2/16/04
to
Hi,

how can I plot two functions with different xranges (overlapping) on the
same graph? Gnuplot doesn't appreciate a square bracket after the comma
following the first function in the plot command.

I don't want a second x-axis.

Thanks for your advice,

Daniel Winkelmann


Hans-Bernhard Broeker

unread,
Feb 16, 2004, 5:36:01 PM2/16/04
to
Daniel Winkelmann <kis...@club-internet.fr> wrote:
> Hi,

> how can I plot two functions with different xranges (overlapping) on the
> same graph? Gnuplot doesn't appreciate a square bracket after the comma
> following the first function in the plot command.

You either have to use parametric mode and map x ranges to the common
t range manually:

x1(t) = 5+(10-5)*t
x2(t) = 8+(16-8)*t
set parametric
set trange [0:1]
plot x1(t), sin(x1(t)) title 'part of a sine', \
x2(t), cos(x2(t)) title 'part of a cosine'

Or you use the '?' operator to define plottable function that are
undefined where you don't want them plotted:

set noparametric
set xrange [0:25]
plot (x<5 || x>10) ? 0/0 : sin(x) title 'part of a sine', \
(x<8 || x > 16) ? 0/0 : cos(x) t 'part of a cosine'


--
Hans-Bernhard Broeker (bro...@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.

Daniel Winkelmann

unread,
Feb 17, 2004, 2:32:06 AM2/17/04
to
Even if I have a bookmark on the page of my copy of Kernighan and Ritchie
that explains the operators I never did much programming in C. It must be
extremely difficult to write efficient help files because you don't dare to
imagine how little the user knows.

Daniel Winkelmann


0 new messages