2
$\begingroup$

I have:

ContourPlot3D[x^2 + y^2 == 1, {x, -2, 2}, {y, -2, 2}, {z, -2, 2},
 MeshFunctions -> {#1 &, #2 &},
 AxesLabel -> {"x", "y", "z"},
 ImageSize -> 300]

Which produces this image.

cylinder

I do want mesh lines parallel to the z-axis, which all of these are, but there is an ugly overlap here. What I really want is some equally spaced mesh lines parallel to the z-axis.

Any suggestions?

$\endgroup$
  • 1
    $\begingroup$ Why not use RevolutionPlot3D[] instead to generate your cylinder? $\endgroup$ – J. M. will be back soon Jun 4 '15 at 21:01
  • $\begingroup$ The most natural representation for use in a RevolutionPlot3D does not work well because the needed function involved DiracDelta functions or other poses problems. $\endgroup$ – David G. Stork Jun 4 '15 at 21:19
4
$\begingroup$

Without changing your choice of ContourPlot3D, you can achieve the desired effect by using the following MeshFunctions option:

ContourPlot3D[x^2 + y^2 == 1, {x, -2, 2}, {y, -2, 2}, {z, -2, 2}, 
 MeshFunctions -> (ArcTan[#1, #2] &), AxesLabel -> {"x", "y", "z"}, 
 ImageSize -> 300]

cyl

You simply have to convert the arguments of the function (which are the x and y coordinates) to an angle around the z axis, using ArcTan.

$\endgroup$
  • $\begingroup$ Perfecto! Exactly what I needed. I'd like to thank the others for their suggestions, RevolutionPlot3D, ParametricPlot3D, but right now I am writing an activity introducing students to ContourPlot3D. $\endgroup$ – David Jun 4 '15 at 21:37
  • 1
    $\begingroup$ @Guess who it is. Thank yo for the edit... $\endgroup$ – Jens Jun 5 '15 at 16:53
  • 1
    $\begingroup$ Yo welcome, of corse. :) $\endgroup$ – J. M. will be back soon Jun 5 '15 at 16:55
0
$\begingroup$
ParametricPlot3D[{Cos[\[Theta]], Sin[\[Theta]], z}, 
{\[Theta], 0, 2 \[Pi]}, {z, -5, 5}]

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.