3
$\begingroup$

I want to combine two plots which are in two regions. For an example, I want to plot following two figures in the same plot.

a = Plot[Cos[x], {x, 0, 60}]
b = Plot[Sin[x], {x, 60, 90}]

Could anyone please tell me how to do this without using Piecewise function?

$\endgroup$

2 Answers 2

8
$\begingroup$
a = Plot[Cos[x], {x, 0, 60}, PlotStyle -> Blue];
b = Plot[Sin[x], {x, 60, 90}, PlotStyle -> Red];
Show[a, b, PlotRange -> All]

Is this what you want?

plot

$\endgroup$
0
1
$\begingroup$

Could anyone please tell me how to do this without using Piecewise function?

Cheating:

Plot[{ConditionalExpression[Cos[x], x <= 60], ConditionalExpression[Sin[x], x >= 60]},
     {x, 0, 90}, PlotStyle -> {Blue, Red}]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.