Struggling with Plot3D for a two function plot

Just not getting anywhere with this 2 function plot, plot 2 functions (plane and cylinder):

Plot3D[{x+3, x^2 + y^2 - 9}, {x, -5, 5}, {y, -5, 5}]

I don’t get a cylinder?

And how do I show axes?

Hi,

ContourPlot3D might help:

ContourPlot3D[{x + 3, x^2 + y^2 - 9}, {x, -5, 5}, {y, -5, 5}, {z, -1, 1}]


. Note that I needed to add a range for the z-coordinate.

Cheers,

Marco

z=x+3 is a plane, but z=x^2 + y^2 - 9 is a paraboloid. You get a plane and a cylinder for example with

Plot3D[{x + 3, Sqrt[9 - x^2]}, {x, -5, 5}, {y, -5, 5}, 
 BoxRatios -> Automatic]

OK, this is good thanks. Interestingly it showed the 1st function as y=x+3, I needed z=x+3, got it working with

ContourPlot3D[{x + 3 - z == 0, x^2 + y^2 - 9 - z == 0}, {x, -5,   5}, {y, -5, 5}, {z, -1, 1}]

Is it a good idea to always use implicit functions?

Also I’d really like to label the axes?

The option for Labels is quite easy to find:

ContourPlot3D[{x + 3 - z == 0, x^2 + y^2 - 9 - z == 0}, {x, -5, 5}, {y, -5, 5}, {z, -1, 1}, 
 AxesLabel -> {"x-axis", "y-axis", "z-axis"}, 
 LabelStyle -> Directive[Bold, Medium, Red]]

Cheers,
Marco

Implict functions are more general than explict functions. Every explicit function such as z==x+3 can be rewritten as an implict function z-x-3==0. Not the converse: x=0 cannot be rewritten as an explict function.
On the other hand, explicit functions are easier to understand. The algorithms for plotting implicit and explicit functions are different.

The choice depends on your particular needs.

Thanks Marco, I had found AxesLabel in the documentation, couldn’t get it to work - maybe because I didn’t have LabelStyle - but this now goes into my ‘cheatsheet’ :slight_smile:

Thanks Gianluca, Could you show a simple example of the difference? I looked them up in documentation but nothing stood out; for example doc. shoiws:

ContourPlot[f,{x,Subscript[x, min],Subscript[x, max]},{y,Subscript[y, min],Subscript[y, max]}]

generates a contour plot of f as a function of x and y.

ContourPlot[f==g,{x,Subscript[x, min],Subscript[x, max]},{y,Subscript[y, min],Subscript[y, max]}]

plots contour lines for which f=g.

A semisphere done in two ways:

Plot3D[Sqrt[1 - (x^2 + y^2)], {x, -1, 1}, {y, -1, 1}]
ContourPlot3D[x^2 + y^2 + z^2 == 1, {x, -1, 1}, {y, -1, 1}, {z, 0, 1}]