Plot[2x, {x,0,4}];
Plot[x^2, {x,4,8}];
How do I merge these two graphs into one?
Answer
Here's a way that may serve you also for other purposes:
p[x_, left_, right_] := HeavisideTheta[x - left] HeavisideTheta[right - x]
Plot[{2 x p[x, 0, 4], x^2 p[x, 4, 8]}, {x, 0, 8}]
Another example:
tab = Table[x^(1/n) p[x, n, n + 1], {n, 1, 10}];
Plot[tab, {x, 0, 8}, PlotStyle -> Thick]
Comments
Post a Comment