# Draw Lines on 3D Plot at certain coordinate

Following this example, I though it would be as easy as this:

Plot3D[1/(x^2 + 1) + 1/(y^2 + 1), {x, -10, 10}, {y, -10, 10},
MeshStyle -> {Black, Black, Red, Green}, Mesh -> {20, 20, 20, 20},
MeshFunctions -> {# &, #2 &, If[# == 5, #] &, If[#2 == 5, #2] &}]


However, this shows only the black mesh. I played around with the number parameter in Mesh-> But that didn't help. How can I draw a red/green line over the plot at a certain x or y position?

Plot3D[1/(x^2 + 1) + 1/(y^2 + 1), {x, -10, 10}, {y, -10, 10},
MeshStyle -> {Black, Black, Red, Green}, Mesh -> {20, 20, {5}, {2}},
MeshFunctions -> {# &, #2 &, # &, #2 &}]


Alternatively, you can specify the mesh divisions for the third and fourth mesh functions as lists of {division, style} pairs:

Plot3D[1/(x^2 + 1) + 1/(y^2 + 1), {x, -10, 10}, {y, -10, 10},
MeshStyle -> Black, Mesh -> {20, 20, {{5, Red}}, {{2, Green}}},
MeshFunctions -> {# &, #2 &, # &, #2 &}]


same picture

• Sometimes it can be as easy as that – infinitezero Sep 25 '19 at 18:35