2
$\begingroup$

I have the following code:

\[Rho][c1_, R_, w_] := -((
   c1 (R^4 + (4 + c1) R^2 w^2 - 3 (-1 + c1) w^4))/((-1 + c1) (R^2 + 
      w^2)^3));
Plot3D[\[Rho][23, R, w], {R, 0, 5}, {w, 0, 5}, 
 PlotRange -> {Automatic, Automatic, {-10, 10}}, 
 AxesLabel -> {"R", "w", "\[Rho]"},
 MeshFunctions -> {(#/Sqrt[22] - #2) &}, MeshStyle -> {Thick, Red}]

It produces the correct plot, but gives too many mesh lines: I only want the one passing through $(0,0)$. How should I modify the code?

$\endgroup$
1
  • $\begingroup$ Mesh -> {{0}}? $\endgroup$ Commented 2 days ago

2 Answers 2

5
$\begingroup$
  • Since the contour line Contours -> {0} through {0,0}, we could set Mesh -> {{0}} to get the mesh line through {0,0}.
f = (#/Sqrt[22] - #2) &;
ContourPlot[f[x, y], {x, 0, 5}, {y, 0, 5}, Contours -> {0}, 
 ContourShading -> None]

enter image description here

f = (#/Sqrt[22] - #2) &;
Plot3D[ρ[23, R, w], {R, 0, 5}, {w, 0, 5}, 
 PlotRange -> {Automatic, Automatic, {-10, 10}}, 
 AxesLabel -> {"R", "w", "ρ"}, 
 MeshFunctions -> {f}, Mesh -> {{0}}, 
 MeshStyle -> {Thick, Red}]

enter image description here

$\endgroup$
1
  • 2
    $\begingroup$ Slight generalization, in which the choice of mesh level {{0}} is almost self-documenting: Whatever valid mesh function f may be, then MeshFunctions -> {f}, Mesh -> {{f[0, 0]}} yields the mesh line(s) along which the function f has the same value as at (0, 0). $\endgroup$ Commented 2 days ago
0
$\begingroup$

I solved the issue: I just had to modify the MeshFunction line as follows:

MeshFunctions -> {If[#/Sqrt[22] == #2,(#/Sqrt[22] - #2)] &}
$\endgroup$

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.