Wolfram mathematica 在Wolfram Mathematica中如何在等高线图和梯度向量场上绘制三维图形

Wolfram mathematica 在Wolfram Mathematica中如何在等高线图和梯度向量场上绘制三维图形,wolfram-mathematica,graphing,wolframalpha,Wolfram Mathematica,Graphing,Wolframalpha,我试图在一个轮廓图和一个梯度向量场(在同一个图上)上绘制一个三维图,这个梯度向量场来自Wolfram Mathematica中的{x,-2,2}和{y,-2,2},用于函数 h(x,y)= −2xe^((−x^2)*(−y^2)) 我得到的代码是: GradVectorField := VectorPlot[{hx[x,y], hy[x,y]}, {x, -2, 2}, {y, -2,2}] contour := ContourPlot[h[x, y], {x, -2, 2}, {y, -2,

我试图在一个轮廓图和一个梯度向量场(在同一个图上)上绘制一个三维图,这个梯度向量场来自Wolfram Mathematica中的{x,-2,2}和{y,-2,2},用于函数

h(x,y)= −2xe^((−x^2)*(−y^2))
我得到的代码是:

GradVectorField := VectorPlot[{hx[x,y], hy[x,y]}, {x, -2, 2}, {y, -2,2}]
contour := ContourPlot[h[x, y], {x, -2, 2}, {y, -2,2}, PlotLegends −> Automatic, ContourLabels −> False]
Show[contour, GradVectorField , PlotLabel −> "title"]
在等高线图上给出梯度向量场

因此,我认为我需要为三维图形添加一个函数,并在“Show”函数中与其他两个图形一起调用它。这是我尝试的代码:

h[x_,y_]:=(-2)*x*e^((-x^2)*(-y^2))
GradVectorField := VectorPlot[{hx[x,y], hy[x,y]}, {x, -2, 2}, {y, -2,2}]
contour := ContourPlot[h[x, y], {x, -2, 2}, {y, -2,2}, PlotLegends->Automatic,ContourLabels->False]
threeDGraph :=Plot3D[{h[x, y]},{x, -2, 2}, {y, -2, 2}, AxesLabel->{x, y, z}, PlotRange->Automatic,PlotLegends->"Expressions",PlotLabel->"h[x,y]"]
Show[contour, GradVectorField ,threeDGraph, PlotLabel->"title"]

上面的代码给出了一系列错误,说明它无法组合两种不同的图形格式(2D和3D以及矢量)。我遗漏了什么?

您可以通过获取构造的图形对象并在所有数据的末尾添加
0
来将2D数据转换为3D。这可以通过使用
2
作为
Join
的最终参数以及
ConstantArray[0,{numPoints,1}]
以及构造良好的
ReplaceAll
有效地实现。然后,可以使用
Epilog
将这些对象插入到3D绘图中,使其位于3D数据下方。谢谢b3m2a1!