Manfred,
There are a number of ways to combine two plots with different domains.
Let's define your two functions.
f1[x_] := 1/2x^2 - x
f2[x_] := -1/2x^2 + x
We could combine them into one function using UnitSteps and make a regular
Plot.
f[x_] := f1[x](UnitStep[x + 3] - UnitStep[x]) +
f2[x](UnitStep[x] - UnitStep[x - 3])
Plot[f[x], {x, -4, 4},
Frame -> True,
PlotRange -> All];
But if you want to deal with them as separate functions you could combine
two plots with the following statement.
Block[{$DisplayFunction = Identity},
g1 = Plot[f1[x], {x, -3, 0}];
g2 = Plot[f2[x], {x, 0, 3}];
]
Show[g1, g2,
Frame -> True,
PlotRange -> {{-4.1, 4.1}, All}];
Here the Block statement gives a local value to $DisplayFunction so as to
supress the side plots. Or you could use the DisplayTogether command from
Graphics`Graphics`.
Needs["Graphics`Graphics`"]
DisplayTogether[
Plot[f1[x], {x, -3, 0}], Plot[f2[x], {x, 0, 3}], Frame -> True,
PlotRange -> {{-4.1, 4.1}, All}];
The last two methods are sometimes a little tricky because they don't always
pick up all Options from the second plot.
Another method is to try the DrawGraphics package from my web site below.
Needs["DrawGraphics`DrawingMaster`"]
Draw2D[
{Draw[f1[x], {x, -3, 0}],
Draw[f2[x], {x, 0, 3}]},
Frame -> True,
PlotRange -> {{-4.1, 4.1}, All}];
Here the Draw statements are like the Plot statement except they just
extract the primitive graphics without making side plots. You could easily
add in other plot type graphics and Lines, Points, Text primitives or
graphics directives, or you could manipulate the primitive graphics before
drawing.
David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/
From: Manfred Fischer [mailto:manfis at t-online.de]
To: mathgroup at smc.vnet.net
Hi,
I want to plot the two functions in one Plot output
+0.5x^2-x (definition-range -3<=x<=0)
-0.5x^2+x (definition-range 0<=x<=3)
I can't find a mathematica 4.0 solution, please help!
-ManFis -