# Controlling what is plotted in a multi-curve plot

My question is on trying to cut off certain plots within a Plot with multiple expressions being plotted. I want to be able to stop the two dashed-line plots at their point of intersection, without affecting how the other two plots are rendered. Please see the image below: Is there a way to limit the plotting range to a certain value for some of the expressions, but not the others? Again, I want the two dashed lines to stop plotting at the point where they intersect. This image shows 4 different plots: two quadratic functions that are offset by 1 and -1, a straight line, and a parabolic function.

EDIT: Code included:

\[Lambda]1 = N[Table[(2 m - 1)/2*\[Pi], {m, 1, Nterms}]];
\[Theta][\[Eta]_, \[Xi]_, Nterms_] := 1 - 2 \!$$\*UnderoverscriptBox[\(\[Sum]$$, $$m = 1$$, $$Nterms$$]$$\*FractionBox[ SuperscriptBox[\((\(-1$$)\), $$m + 1$$], $$\[Lambda]1[\([$$$$m$$$$]$$]\)] Cos[\ \[Lambda]1[$$[$$\
$$m$$$$]$$]*\[Eta]]*Exp[$$-4$$*
\*SuperscriptBox[$$\[Lambda]1[\([$$$$m$$$$]$$]\), $$2$$]\ \[Xi]]\)\)

Manipulate[
Rotate[
Plot[
{
a (η - 1)^2,
a (η + 1)^2,
xL + 0.2*θ[η, ξ, Nterms],
xL
},
{η, -1, 1},

PlotRange -> {0, 1},
Filling -> {3 -> xL},
PlotStyle ->
{
{Thick, Dashed, ColorData[1, 2]},
{Thick, Dashed, ColorData[1, 2]},
{Thick, ColorData[1, 1]},
{Thick, ColorData[1, 2]}
},
AspectRatio -> 1.5
]
, rotateAngle],

{ξ, 0, 0.1},
{xL, 0, 1},
{{a, 1}, 0, 1},
{{rotateAngle, -Pi/2}, {0, -Pi/2}}
]


EDIT: A solution with Show and 3 Plots, but I would prefer a more elegant way to do this inside of one Plot command:

Manipulate[
Rotate[Show[
Plot[{a (\[Eta] - 1)^2}, {\[Eta], 0, 1},
PlotRange -> {{-1, 1}, {0, 1}},
PlotStyle -> {Thick, Dashed, ColorData[1, 2]}, AspectRatio -> 1.5],

Plot[{a (\[Eta] + 1)^2}, {\[Eta], -1, 0},
PlotRange -> {{-1, 1}, {0, 1}},
PlotStyle -> {Thick, Dashed, ColorData[1, 2]}, AspectRatio -> 1.5],

Plot[
{xL + 0.2*\[Theta][\[Eta], \[Xi], Nterms], xL}, {\[Eta], -1, 1},
PlotRange -> {0, 1}, Filling -> {1 -> xL},
PlotStyle -> {{Thick, ColorData[1, 1]}, {Thick, ColorData[1, 2]}},
AspectRatio -> 1.5]
], rotateAngle],

{\[Xi], 0, 0.1},
{xL, 0, 1},
{{a, 1}, 0, 1},
{{rotateAngle, -Pi/2}, {0, -Pi/2}}
] • xL + 0.2*\[Theta][\[Eta], \[Xi], Nterms], is missing. – Öskå May 15 '14 at 16:11
• They are pretty complex orthogonal series expansion functions, so I excluded them~ Nterms is just the number of terms the summation carries out to. I'll add it in, one sec – madacho May 15 '14 at 16:13
• Well, it doesn't matter for the "cutting plot" issue anyway :) – Öskå May 15 '14 at 16:14
• Any value for Nterms..? – Öskå May 15 '14 at 16:21
• Set to 30 at the moment – madacho May 15 '14 at 16:23

## 2 Answers

Update: Combining all plots in a single one and using ConditionalExpression to control the pieces to draw:

 Manipulate[
Rotate[Plot[{ConditionalExpression[a (\[Eta] - 1)^2, 0 < \[Eta] <= 1],
ConditionalExpression[a (\[Eta] + 1)^2, -1 < \[Eta] <= 0],
xL + 0.2*\[Theta][\[Eta], \[Xi], Nterms],
xL},
{\[Eta], -1, 1}, PlotRange -> {{-1, 1}, {0, 1}},
Filling -> {3 -> xL},
PlotStyle -> {Directive[Thick, Dashed, ColorData[1, 2]],
Directive[Thick, Dashed, ColorData[1, 2]],
Directive[Thick, ColorData[1, 1]],
Directive[Thick, ColorData[1, 2]]}, AspectRatio -> 1.5],
rotateAngle],
{\[Xi], 0, 0.1}, {xL, 0, 1}, {{a, 1}, 0,1}, {{rotateAngle, -Pi/2}, {0, -Pi/2}}] Another way is to use the option RegionFunction:

y1[x_] := Sqrt@x - 1
y2[x_] := -Sqrt@x + 1
Plot[{y1[x], y2[x]}, {x, 0, 2}, RegionFunction -> Function[{x, y}, y1[x] < y2[x]]] The settings RegionFunction -> (y1[#] < y[#] &) and RegionFunction -> (# < 1 &) will also work.

• kguler, I'm not sure how this works: are you basically setting a function that is making a region where the Plots will be cut off at? What will happen if there are additional plots inside, will they be cutoff at the intersection point as well? – madacho May 15 '14 at 16:31
• @madacho correct.. see RegionFunction. – kglr May 15 '14 at 16:34
• Awesome! Thanks so much, that works perfectly, kudos! – madacho May 15 '14 at 17:42
• @madacho, glad it was useful. Thank you for the accept. – kglr May 15 '14 at 18:26
y1[x_] := Sqrt@x - 1
y2[x_] := -Sqrt@ x + 1
Plot[{y1[x], y2[x]}, {x, 0, x /. Last@Solve[y1[x] == y2[x]]}, PlotRange->{{0, 2}, {-1, 1}}] or you can play with PlotRange:

Plot[{y1[x], y2[x]}, {x, 0, 10},
PlotRange -> {{0, x /. Last@Solve[y1[x] == y2[x]]}, {-1, 1}}] • May I edit with my solution..? :) – Öskå May 15 '14 at 16:03
• @Öskå Be my guest :=) – Dr. belisarius May 15 '14 at 16:04
• I figured out a way to do it with Show and 3 Plots, one for each of the quadratic functions (dashed lines), and the third that combines the other 2 functions. However, the idea was to be able to do this all in one Plot command. Thanks for the solutions Oska and belisarius, I'm going to try them out to see if they'll work for me now! – madacho May 15 '14 at 16:12
• I want to be able to adjust the location of the intersection point, while having the plots stop after that point, if that clears things up a bit more. I have a Slider for the coefficient "a" that does this inside of the Manipulate. – madacho May 15 '14 at 16:16
• Yes, I was just wondering if there was a way to specify domains for specific functions inside of one Plot command. The Show and Plot combination works how I want it to, just looks a bit inefficient with three Plots where one could do nicely. – madacho May 15 '14 at 16:19