#### QUESTION

```
Show[Plot[Sin[x], {x, 0, \[Pi]}, PlotStyle -> Red,
PlotRange -> {{0, 2 \[Pi]}, {-1, 1}}],
Plot[Sin[x], {x, \[Pi], 2 \[Pi]}, PlotStyle -> Green,
PlotRange -> {{0, 2 \[Pi]}, {-1, 1}}]]
```

Is there a simpler way of doing this? Especially, one that does not require repeating the Plot command 2 times ;)

#### ANSWER

```
Plot[Sin[x], {x, 0, 2 \[Pi]}, PlotStyle -> Thick,
ColorFunction -> Function[{x, y}, If[x < Pi, Red, Blue]],
ColorFunctionScaling -> False,
PlotRange -> {{0, 2 \[Pi]}, {-1, 1}}]
```

or

```
Plot[Sin[x], {x, 0, 2 \[Pi]}, PlotStyle -> Thick,
Mesh -> {{Pi}},
MeshShading -> {Red, Blue},
PlotRange -> {{0, 2 \[Pi]}, {-1, 1}}]
```

or

```
Plot[{ConditionalExpression[Sin[x], 0 <= x <= Pi],
ConditionalExpression[Sin[x], Pi <= x <= 2 Pi]}, {x, 0, 2 Pi},
PlotStyle -> {Directive[Thick, Red], Directive[Thick, Blue]}]
```

Tweet