plot [0:10] x, [-10:10] -x
Suppose I want to plot two different functions with different xrange.
Is it possbile to do it in gnuplot directly, if know the explicit form
for each functions?
Or I have to right data for each function into files and plot from
these files?
Thanks,
Peng
> plot [0:10] x, [-10:10] -x
> Suppose I want to plot two different functions with different xrange.
You can do this with the ternary operator (see 'help ternary'). Try the
following (based on your example above):
set xrange [-10:10]
g(x,min,max)=( (x>=min && x<=max)? 1.0 : (1/0) )
plot x*g(x,0,10) with line, -x*g(x,-10,10) with line
If you're finding that the lines don't quite meet at the boundaries, try
increasing 'samples' to 200.
set samples 200
Hope that helps,
steve
> Suppose I want to plot two different functions with different xrange.
> Is it possbile to do it in gnuplot directly, if know the explicit form
> for each functions?
Not quite.
> Or I have to right data for each function into files and plot from
> these files?
No. There are two alternatives:
1) plotting a function, but setting its value to "undefined" where you
don't want it plotted. See Steve Bickerton's earlier answer.
2) The generic "strange curve plotting cure": parametric mode
set parametric
set trange [0:1]
x1(t)=-10+10*t
x2(t)=-10+20*t
plot x1(t), f1(x1(t)) title "f1(x)", \
x2(t), f2(x2(t)) title "f2(x)"