# How to combine Plot, Manipulate and ContourPlot [closed]

I want to combine "Plot, Manipulate and ContourPlot", into one graphics display.

I tried Show[plot1, plot2, ...] but it didn't work.

f[x_] := 1 - (x - 4)^2
g[x_] := 0.6 x + 1

plot1 =
Manipulate[
Plot[{n f[x] + g[x], f[x], g[x]}, {x, 2, 6},
PlotRange -> 8, AspectRatio -> 1],
{n, 1, 5.5}]

plot2 =
ContourPlot[{x == 3, x == 5}, {x, 2, 6}, {y, -5, 5},
Frame -> False, Axes -> True]

Show[plot1, plot2] ## closed as off-topic by MarcoB, user9660, Jens, RunnyKine, ubpdqnMar 13 '16 at 8:48

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – MarcoB, Community, Jens, RunnyKine, ubpdqn
If this question can be reworded to fit the rules in the help center, please edit the question.

• Use Show inside Manipulate. Also use With to inject ContourPlot so it won't be recalculated each time. – Kuba Mar 12 '16 at 12:05

Since you're just using ContourPlot[] for the vertical lines, I would suggest using the GridLines option instead:

Manipulate[Plot[{n f[x] + g[x], f[x], g[x]}, {x, 2, 6},
AspectRatio -> 1, Axes -> None, Frame -> True,
GridLines -> {{{3, ColorData[97, 1]}, {5, ColorData[97, 2]}}, None},
GridLinesStyle -> AbsoluteThickness[1.6],
PlotRange -> {-4.1, 9.1}],
{{n, 3.25}, 1, 5.5, Appearance -> "Labeled"}]


or if you have version 10, the new InfiniteLine[] primitive:

Manipulate[Plot[{n f[x] + g[x], f[x], g[x]}, {x, 2, 6},
AspectRatio -> 1, Axes -> None,
Epilog -> {AbsoluteThickness[1.6],
{{ColorData[97, 1], InfiniteLine[{3, 0}, {0, 1}]},
{ColorData[97, 2], InfiniteLine[{5, 0}, {0, 1}]}}},
Frame -> True, PlotRange -> {-4.1, 9.1}],
{{n, 3.25}, 1, 5.5, Appearance -> "Labeled"}]


Put the Show inside of the Manipulate

f[x_] := 1 - (x - 4)^2
g[x_] := 0.6 x + 1

plot2 = ContourPlot[{x == 3, x == 5},
{x, 2, 6}, {y, -5, 9.1}];

Manipulate[
Show[
Plot[{n f[x] + g[x], f[x], g[x]},
{x, 2, 6},
Frame -> True,
Axes -> False,
PlotRange -> {-4.1, 9.1},
AspectRatio -> 1],
plot2],
{{n, 3.25}, 1, 5.5, Appearance -> "Labeled"}] 