# Is it possible to ask Mathematica to stick two plots together to give a continuous plot ? (An example is given)

I want to plot a function over a large range of $$x$$. The problem is that for very large $$x$$, even increasing PlotPoint to $$5\times10^6$$ and MaxRecursion 15, it does not give the whole result. But I can get an accurate result for a short domain.

Then, is it possible to ask Mathematica to stick the plots together to give something like a continuous plot over a large range?

For example, if I have

P1 = Plot[{0, If[Sin[x \[Pi]] >= 0, 1000]}, {x, 0, 10},
PlotStyle -> {Directive[White, CapForm["Butt"], Opacity[-1],
Thickness[0]],
Directive[Red, CapForm["Butt"], Opacity[1000], Thickness[.04]]},
PlotPoints -> 50, MaxRecursion -> 6, AspectRatio -> 1/40,
Axes -> {True, False}, Ticks -> {{0, 5, 10}, {0, 0}}]
P2 = Plot[{0, If[Cos[x \[Pi]] >= 0, 1000]}, {x, 10, 20},
PlotStyle -> {Directive[White, CapForm["Butt"], Opacity[-1],
Thickness[0]],
Directive[Blue, CapForm["Butt"], Opacity[1000], Thickness[.04]]},
AspectRatio -> 1/40, Axes -> {True, False},
Ticks -> {{10, 15, 20}, {0, 0}}]



which the result is this

then, how to ask Mathematica to stick them as a continuous plot and gives something like this

Is it possible?

## 1 Answer

Show[P1, P2, PlotRange -> All, Ticks -> Automatic]


• +1 That was an easy one :-) Nov 9, 2020 at 21:58