2

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?

infinitezero
  • 1,419
  • 8
  • 18

1 Answers1

4
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 &}]

enter image description here

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

kglr
  • 394,356
  • 18
  • 477
  • 896