【求助】ContourPlot中2D转3D的问题
mathematica吧
全部回复
仅看楼主
level 2
京极园子 楼主
对于一个方程我用ContourPlot作出了2D图
nmax = 40;
c[n_] := v (1 - (-1)^n) *2/(n*Pi*Sinh[n*Pi*b/a]);
\[Phi] = Sum[c[n]*2/a*Sin[n*Pi*x/a]*Sinh[n*Pi*y/a], {n, 1, nmax}];
v = 1;
a = 1;
b = 1;
ContourPlot[\[Phi], {x, 0, a}, {y, 0, b}, PlotPoints -> 35,
Contours -> 40, ColorFunction -> Hue]
如何转换成3D的呢?希望图形能在xy-面上,方程在z上没有定义。
此外如何表示求和中n=1,3,5...11?
2017年05月20日 20点05分 1
level 9
首先,这个可以使用SliceContourPlot3D:
SliceContourPlot3D[\[Phi], z == 0, {x, 0, a}, {y, 0, b}, {z, 0, 1},
PlotPoints -> 35, Contours -> 40, ColorFunction -> Hue,
PerformanceGoal -> "Quality"]
这个函数是版本10以后才有的,不过看起来好像效果不是特别好
2017年05月21日 03点05分 2
level 9
还有一个方法, 比较麻烦,使用 模式匹配把二维数据提取出来转换为3维,只是每一个具体问题要具体对待。
首先 令原图为pic
nmax = 40;
c[n_] := v (1 - (-1)^n)*2/(n*Pi*Sinh[n*Pi*b/a]);
\[Phi] = Sum[c[n]*2/a*Sin[n*Pi*x/a]*Sinh[n*Pi*y/a], {n, 1, nmax}];
v = 1;
a = 1;
b = 1;
pic = ContourPlot[\[Phi], {x, 0, a}, {y, 0, b}, PlotPoints -> 35,
Contours -> 40, ColorFunction -> Hue]
然后再转换:
Graphics3D[
Cases[Normal@
pic, {EdgeForm[], Hue[x_], GraphicsGroup[y_]} :> {EdgeForm[],
Hue[x], GraphicsGroup[y]},
Infinity] /. {x_Real, y_Real} -> {x, y, 0}, PlotRange -> {0, 1}]
2017年05月21日 04点05分 3
[惊讶]原来还可以这样,感谢!
2017年05月21日 08点05分
1