# Vertical rulings for a cylinder

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.

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?

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

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]


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.

• 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. – David Jun 4 '15 at 21:37
• @Guess who it is. Thank yo for the edit... – Jens Jun 5 '15 at 16:53
• Yo welcome, of corse. :) – J. M. is away Jun 5 '15 at 16:55
ParametricPlot3D[{Cos[\[Theta]], Sin[\[Theta]], z},
{\[Theta], 0, 2 \[Pi]}, {z, -5, 5}]