When plotting a 3D Graphic, how to define the angle it will show?
I know I can after the plot is done, to rotate it with my mouse to the desired angle. Now, I'd like to k开发者_如何学编程now how to do the same through code.
The 3D view is most conveniently defined through the parameters ViewPoint
and ViewVertical
(There are additional options: ViewCenter
, ViewVector
, and ViewAngle
, but it usually suffices to leave them on Automatic
).
So you can do for example
Plot3D[Cos[x^2 + y^2], {x, -3, 3}, {y, -3, 3}, ViewPoint -> {3, 2, 1}]
To get good values for ViewPoint
, etc. I define a function Get3DView
as
Get3DView[gfx_] :=
Options[Unevaluated[gfx], {ViewCenter, ViewVector, ViewVertical, ViewPoint}]
Then you just copy your graphics into Get3DView
to get your options:
plotpar = Get3DView[<your graphics pasted here>]
After this you can put your plotpar
as options for new plot commands (note the Evaluate):
Plot3D[Cos[x^2 + y^2], {x, -3, 3}, {y, -3, 3}, Evaluate@plotpar]
On second look your title involves 3d rotation. For that you can use ViewPoint. The example under the applications tab seems to be what you are looking for.
You can use the ImageRotate function.
ImageRotate@Plot[x, {x, 0, 10}] (*rotate 90 degrees counterclockwise*)
ImageRotate[Plot[x, {x, 0, 10}], phi] (*rotate phi degrees counterclockwise*)
精彩评论