2
$\begingroup$
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.

$\endgroup$
  • 3
    $\begingroup$ Show[ {Plot[Sin[x], {x, 0, 10}, Mesh -> {{0, \[Pi]}}, MeshShading -> {Black, Red}], Plot[Cos[x], {x, 0, 10}, Mesh -> {{0, \[Pi]}}]}] $\endgroup$ – Dr. belisarius Feb 7 '13 at 16:59
  • 1
    $\begingroup$ @belisarius Isn't this what the OP explicitly says he doesn't want, or am I misreading this? $\endgroup$ – Sjoerd C. de Vries Feb 7 '13 at 21:52
  • 3
    $\begingroup$ @SjoerdC.deVries Yup. But my preferred shoe shop doesn't sell pairs of two right shoes unless you can convince them -with good reasons- $\endgroup$ – Dr. belisarius Feb 7 '13 at 21:59
  • $\begingroup$ 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? $\endgroup$ – Mr.Wizard Mar 10 '13 at 19:09
  • $\begingroup$ Related: mathematica.stackexchange.com/q/1128/121 $\endgroup$ – Mr.Wizard Mar 10 '13 at 19:12
1
$\begingroup$
Plot[{ConditionalExpression[Sin[x], 0 <= x <= Pi], 
      ConditionalExpression[Sin[x], Pi < x <= 10], Cos[x]}, {x, 0, 10}, 
      PlotStyle -> {Red, Black, Black}]

enter image description here

$\endgroup$
  • 3
    $\begingroup$ This doesn't use Mesh at all, in contrast to what the question title states. $\endgroup$ – Jens Feb 9 '13 at 0:14
  • 1
    $\begingroup$ It is a good answer if the real question is how to generate that plot... $\endgroup$ – SEngstrom May 9 '13 at 15:32
0
$\begingroup$
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]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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