# Using mesh for a single function inside Plot

Plot[{Sin[x], Cos[x]}, {x, 0, 10}, Mesh -> {{0, π}}, MeshShading -> {Black, Red}]


In the above, how can I specify that I want the mesh for just, say the Sin function and not the Cos? I know I can use two plots and combine them with Show, but this is not what I want.

• Show[ {Plot[Sin[x], {x, 0, 10}, Mesh -> {{0, \[Pi]}}, MeshShading -> {Black, Red}], Plot[Cos[x], {x, 0, 10}, Mesh -> {{0, \[Pi]}}]}] – Dr. belisarius Feb 7 '13 at 16:59
• @belisarius Isn't this what the OP explicitly says he doesn't want, or am I misreading this? – Sjoerd C. de Vries Feb 7 '13 at 21:52
• @SjoerdC.deVries Yup. But my preferred shoe shop doesn't sell pairs of two right shoes unless you can convince them -with good reasons- – Dr. belisarius Feb 7 '13 at 21:59
• Since your own answer has nothing to do with Mesh shall we assume that you just want output that visually matches the graphic shown in that answer? – Mr.Wizard Mar 10 '13 at 19:09
• – Mr.Wizard Mar 10 '13 at 19:12

Plot[{ConditionalExpression[Sin[x], 0 <= x <= Pi],
ConditionalExpression[Sin[x], Pi < x <= 10], Cos[x]}, {x, 0, 10},
PlotStyle -> {Red, Black, Black}] • This doesn't use Mesh at all, in contrast to what the question title states. – Jens Feb 9 '13 at 0:14
• It is a good answer if the real question is how to generate that plot... – SEngstrom May 9 '13 at 15:32
Plot[{Sin[x], Cos[x]}, {x, 0, 4 Pi},
MeshFunctions -> {Boole[#2 === Sin[#1]] # &},
Mesh -> {{0, Pi, 2 Pi, 3 Pi, 4 Pi}},
MeshShading -> {Black, Directive[ Red, Thick]},
PlotPoints -> 900] 