3
$\begingroup$

I want to assign different color for horizontal lines (x=0.25, x=0.5, x=0.75) in the 3D plot of $f(x,y)= x^2y$.

f[x_, y_] := x^2 y
p1 = Plot3D[f[x, y], {x, 0, 1}, {y, 0, 1}, MeshFunctions -> (#1 &), 
   MeshStyle -> {{Red, Thick}, {Green, Thick}, {Blue, Thick}}, 
   Mesh -> {{{0.25}, {0.5}, {0.75}}}, PlotLabel -> "F(x,y)"]

The resulting graph is as follow,

enter image description here

As you can see the different colors hadn't applied and all three lines are red. I'm wondering how to change the color of lines to Red, Blue and Green respectively?

$\endgroup$

1 Answer 1

7
$\begingroup$
f[x_, y_] := x^2 y
p1 = Plot3D[f[x, y], {x, 0, 1}, {y, 0, 1}
  , MeshFunctions -> (#1 &)
  , Mesh -> {
    {{0.25, {Red, Thick}}
     , {0.5, {Green, Thick}}
     , {0.75, {Blue, Thick}}}
    }
  , PlotLabel -> "F(x,y)"
  ]

enter image description here

$\endgroup$

Your Answer

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

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