0

我知道我可以在绘图完成后用鼠标将其旋转到所需的角度。现在,我想知道如何通过代码来做同样的事情。

4

2 回答 2

2

3D 视图通过参数ViewPoint和最方便地定义ViewVertical(还有其他选项:ViewCenterViewVectorViewAngle,但通常将它们保留在 上就足够了Automatic)。

所以你可以做例如

Plot3D[Cos[x^2 + y^2], {x, -3, 3}, {y, -3, 3}, ViewPoint -> {3, 2, 1}]

为了获得良好的价值ViewPoint,等等。我将一个函数定义Get3DView

Get3DView[gfx_] := 
  Options[Unevaluated[gfx], {ViewCenter, ViewVector, ViewVertical, ViewPoint}]

然后,您只需将图形复制到其中Get3DView即可获得您的选择:

plotpar = Get3DView[<your graphics pasted here>]

在此之后,您可以将您的plotparas 选项设置为新的绘图命令(注意 Evaluate):

Plot3D[Cos[x^2 + y^2], {x, -3, 3}, {y, -3, 3}, Evaluate@plotpar]
于 2010-02-16T16:42:52.363 回答
1

再看一遍,您的标题涉及 3d 旋转。为此,您可以使用ViewPoint。应用程序选项卡下的示例似乎是您正在寻找的。

您可以使用ImageRotate功能。

ImageRotate@Plot[x, {x, 0, 10}] (*rotate 90 degrees counterclockwise*)
ImageRotate[Plot[x, {x, 0, 10}], phi]  (*rotate phi degrees counterclockwise*)
于 2009-12-21T19:57:54.253 回答