Mathematica, gradient plot on the graph

In summary, the conversation is about plotting a vector field 2x, 2y, 0 which is the gradient of the function x^2+y^2. The person tried using ListVectorPlot3D to plot it only at certain points on the paraboloid, but it did not work. They are asking for ideas on how to plot the gradient on the paraboloid without having to manually plot each vector. The solution involves using VectorPlot3D, Plot3D, and adjusting the vector starting points to be at the actual points on the paraboloid.
  • #1
PeetPb
29
0
Hi,
I need to plot a vector field 2x,2y,0 which is the gradient of the function x^2+y^2. I need to plot it only in some interesting points (points on the paraboloid x^2+y^2). So I tried something like

a=Table[{{x,y,x^2+y^2},{2x,2y,0}},{x,-2,2,0.5},{y,-2,2,0.5}]
ListVectorPlot3D[a]

It did not work. The definition of ListVectorPlot3D[{{x,y,z},{a,b,c}},...] says that it generates a 3D vector plot from vector field values {a,b,c} given at specified points {x,y,z}.

Any idea how I might plot that gradient on the paraboloid ? It would be really unpleasant if I had to do every single vector with Graphics3D[]

thanks
 
Physics news on Phys.org
  • #2
Code:
pnts = Flatten[Table[{x, y, x^2 + y^2}, {x, -2, 2, 1/4}, {y, -2, 2, 1/4}], 1];

plv = VectorPlot3D[{2 x , 2 y, 0}, {x, -2, 2}, {y, -2, 2}, {z, 0, 8},  VectorPoints -> pnts, VectorColorFunction -> "ThermometerColors",    VectorScale -> Small];

plp = Plot3D[x^2 + y^2, {x, -2, 2}, {y, -2, 2},  ColorFunction -> "GrayTones", BoxRatios -> {3, 3, 2}];

Show[plp, plv, ImageSize -> 600]

Gives me this: It took me a bit of time, but I have always wanted to learn how to do this anyway so 30 minutes well spent.

Does anyone know how i can make the arrows START at the point rather than be centered at it?
 

Attachments

  • arrowsonparabola.jpg
    arrowsonparabola.jpg
    36.4 KB · Views: 1,280
Last edited:

1. What is Mathematica?

Mathematica is a software program developed by Wolfram Research that is used for mathematical and scientific computing. It is commonly used by scientists, engineers, and mathematicians for data analysis, visualization, and programming.

2. How do I create a gradient plot on a graph using Mathematica?

To create a gradient plot on a graph in Mathematica, you can use the GradientPlot function. This function takes in a function or data points and creates a gradient color representation of the function or data on a 2D or 3D graph.

3. Can I customize the gradient colors on a Mathematica plot?

Yes, you can customize the gradient colors on a Mathematica plot by using the ColorFunction option in the GradientPlot function. This allows you to choose from a variety of built-in color schemes or create your own custom color function.

4. How do I add labels and legends to a gradient plot in Mathematica?

To add labels and legends to a gradient plot in Mathematica, you can use the PlotLabel and PlotLegends options in the GradientPlot function. These options allow you to specify the labels and legends you want to display on the plot.

5. Can Mathematica create gradient plots for 3D data?

Yes, Mathematica can create gradient plots for 3D data using the GradientPlot3D function. This function works similarly to the GradientPlot function but allows you to visualize 3D data with gradient colors.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
200
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
479
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
593
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
155
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
830
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
Back
Top