# Plot The volume of a cylinder between a cone and XY

I want to plot the volume of a cylinder between a cone and the plane XY

The equation of the cone is $z$ $=$ $\sqrt{x^2 + y^2}$ and the cylinder equation $y^2 - 2y + x^2 = 0$

I am using the following code to plot the graphs:

      p3 =  Plot3D[{Sqrt[x^2 + y^2], 0}, {x, -2, 6}, {y, -5, 5}]
p4 = ContourPlot3D[{y^2 - 2 y + x^2 == 0}, {x, -5, 5}, {y, -5,
5}, {z, -5, 5}]
show [p3,p4]


And I get the following

How can I plot only the volume of the cylinder between the cone and the plane XY

• Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! Apr 28, 2015 at 23:34

You can use the RegionFunction option on ContourPlot3D to only plot the cylinder above the plane and below the cone.

ContourPlot3D[{y^2 - 2 y + x^2 == 0}, {x, -5, 5}, {y, -5, 5}, {z, -5, 5},
RegionFunction -> Function[{x, y, z}, 0 <= z <= Sqrt[x^2 + y^2]]]


### Edit

The above is correct, but the plot will look better if it is focused on the relevant region.

ContourPlot3D[
y^2 - 2 y + x^2 == 0, {x, -1, 1}, {y, 0, 2}, {z, 0, 2.5},
RegionFunction -> Function[{x, y, z}, 0 <= z <= Sqrt[x^2 + y^2]],
BoxRatios -> {2, 2, 2.5}]


• I edited your answer to show how the plot can be focused on the relevant region by making a more suitable choice of plot range. Apr 29, 2015 at 2:59

The solution provided by @Edmund does not show the top (curved) face of the region. The following does:

RegionPlot3D[z < Sqrt[x^2 + y^2 ] && y^2 - 2 y + x^2 < 0 && z > 0,
{x, -1.5, 1.5}, {y, -.5, 2}, {z, 0, 2},
PlotPoints -> 100]