Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 8 down vote accepted
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

share|improve this answer
    
Thanks Federico. –  TMH Mar 27 '13 at 0:31
    
You are welcome –  Federico Mar 27 '13 at 0:34

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}]
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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