English 中文(简体)
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 know how to do the same through code.

最佳回答

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*)
问题回答

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]




相关问题
Solving vector equations in Mathematica

I m trying to figure out how to use Mathematica to solve systems of equations where some of the variables and coefficients are vectors. A simple example would be something like where I know A, V, and ...

Introspection of messages generated in Mathematica

Is there any way to get at the actual messages generated during the evaluation of an expression in Mathematica? Say I m numerically solving an ODE and it blows up, like so In[1] := sol = NDSolve[{x [...

Connecting points in Mathematica

I have a collection of points displayed in a graphic: alt text http://img69.imageshack.us/img69/874/plc1k1lrqynuyshgrdegvfy.jpg I d like to know if there is any command that will connect them ...

Mathematica, PDF Curves and Shading

I need to plot a normal distribution and then shade some specific region of it. Right now I m doing this by creating a plot of the distribution and overlaying it with a RegionPlot. This is pretty ...

Targeted Simplify in Mathematica

I generate very long and complex analytic expressions of the general form: (...something not so complex...)(...ditto...)(...ditto...)...lots... When I try to use Simplify, Mathematica grinds to a ...

热门标签