1
$\begingroup$

I am attempting to place the vector plot for the function f(x,y)=x^2+y^2 underneath my graph of the function but I cannot figure out how to graph them together. This is my attempt, but I am sure where to go from here.

f[x_,y_]=x^2+y^2
P1=Plot3D[f[x,y],{x,-10,10},{y,-10,10},
ClippingStyle->Off,
AxesLabel->{x,y,z},
AxesOrigin->{0,0,0},
Boxed->False,
ColorFunction->"Rainbow"]
P2=Graphics3D[{Opacity[0.3],InfinitePlane[{{1,0,0},{0,1,0},{0,0,0}}]},
AxesLabel->{x,y,z},
AxesOrigin->{0,0,0},
Boxed->False]
P3=VectorPlot[Evaluate@Grad[f[x, y], {x, y}], {x, -2, 2}, {y, -2, 2}, 
 PlotLegends -> None]
Show[P1,P2,P3]

Thanks for your help

$\endgroup$

1 Answer 1

3
$\begingroup$
$Version

(* "13.2.0 for Mac OS X x86 (64-bit) (November 18, 2022)" *)

Clear["Global`*"]

f[x_, y_] = x^2 + y^2;

P1 = Plot3D[f[x, y], {x, -10, 10}, {y, -10, 10}, 
    ClippingStyle -> Off,
    AxesLabel -> {x, y, z}, 
    AxesOrigin -> {0, 0, 0}, 
    Boxed -> False, 
    ColorFunction -> "Rainbow"];

P3 = VectorPlot[
   Evaluate@Grad[f[x, y], {x, y}], {x, -10, 10}, {y, -10, 10}, 
   PlotLegends -> None];

P2 = Graphics3D[{Arrowheads[Small], 
       (Cases[P3, {_LABColor, _Arrow}, Infinity] /. 
        {x_?NumericQ, y_?NumericQ} :> {x, y, 0}), 
    Opacity[0.3], 
    InfinitePlane[{{1, 0, 0}, {0, 1, 0}, {0, 0, 0}}]}, 
   AxesLabel -> {x, y, z}, 
   AxesOrigin -> {0, 0, 0}, 
   Boxed -> False];

Show[P1, P2]

enter image description here

$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.