Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am trying to show how a vector M varies over time. I have the following code:

Mx={4.74124,13.1038,33.0248,19.7323,24.5952,30.1253,27.9521,29.4089,28.0574,29.277};
My={-18.2975,-7.42215,-4.23518,-9.88457,-8.96098,-8.22531,-9.6019,-9.18352,-9.06551,-9.29939};
Mz={-0.12887,-7.57926,-1.4561,-1.59703,-4.53247,-2.09772,-2.91711,-3.56798,-2.6221,-3.48453};

Animate[

Graphics3D[{
Blue,Arrow[Tube[{{0,0,0},{Mx[[i]],My[[i]],Mz[[i]]}}]]
},Axes->True,AxesLabel->{"x","y","z"},Axes],

{i,1,Length[Mx],1}]

(In actuality, my lists Mx, My, and Mz are much longer, but the shorter lists above reproduce the error behavior.)

I get the following error:

An improperly formatted option was encountered while reading a Graphics3DBox. The option was not in the form of a rule.

Do you know how I can fix this? I do not understand which option "was not in the form of a rule."

share|improve this question
add comment

2 Answers 2

up vote 8 down vote accepted

You have a stray argument in the Graphics3D function (Axes).
Also, you probably want a fixed PlotRange. Try:

Animate[
 Graphics3D[{Blue, 
    Arrow[Tube[{{0, 0, 0}, {Mx[[i]], My[[i]], Mz[[i]]}}]]}, 
    Axes -> True, AxesLabel -> {"x", "y", "z"}, 
    PlotRange -> ({Min@# - 5, Max@# + 5} & /@ {Mx, My, Mz})],
 {i, 1, Length[Mx], 1}
]

Mathematica graphics


In the future try to debug your own code. You would have seen the same problem without the Animate function if you tried that. Also, the error code suggests that something is wrong with the graphics options, which should have directed your attention to the arguments of Graphics3D.

share|improve this answer
    
Thanks. I have voted to close my question as being too localized. (I missed my silly mistake.) –  Andrew May 26 '12 at 22:41
    
Or maybe I should delete the question? What do you think? –  Andrew May 26 '12 at 22:52
    
@Andrew I'd rather have the points but I'm OK with it. :-) –  Mr.Wizard May 26 '12 at 23:33
    
I think the fixed plot range is a reasonable question. The stray Axes that was causing the error can just be edited out of the question. –  Brett Champion May 27 '12 at 1:55
    
@Andrew see Brett's comment above. –  Mr.Wizard May 27 '12 at 2:05
add comment

You may also play some tricks:

h = Transpose[Table[{Cos@t, Sin@t, t^.1}, {t, 0, 8 Pi, .1}]];
d = Interpolation[#, InterpolationOrder -> 1] & /@ h;

Manipulate[
 Show[
  Graphics3D[{Blue, Arrow[Tube[{{0, 0, 0}, Through@d@t}]]}, Axes -> True, 
              AxesLabel -> {x,y,z}, PlotRange -> ({1.1 Min@#, 1.1 Max@#} & /@ h)],

  ParametricPlot3D[Through@d@v, {v, 1, t}, ColorFunction -> Function[{x, y, z, u}, Hue[z]]]],
 {t, 1.001, Length@First@h}
]

Full Movie Link

enter image description here

Edit

Fancier, by using InterpolatingFunctio[] properties:

<< DifferentialEquations`InterpolatingFunctionAnatomy`

pltIntFun[d:{_InterpolatingFunction ..}]:=Module[{pRange,manipDomain,k = (Max@# - Min@#) 10^-4 &},

   pRange      = { Min@# - k@#, Max@# + k@#} & /@ Through@d@"ValuesOnGrid";
   manipDomain = Join[{t}, ({ Min@# + k@#, Max@#} & /@ Through@d@"Domain")[[1]]];

   Manipulate[Show[
     Graphics3D[
      {Blue, Arrow[Tube[{{0, 0, 0}, Through@d@t}]]}, 
       Axes -> True, AxesLabel -> {x, y, z}, PlotRange -> pRange],

     ParametricPlot3D[Through@d@v, {v, 1, t}, ColorFunction -> Function[{x, y, z, u}, Hue[z]]]],
                      Evaluate@manipDomain]];


d = Interpolation[#,InterpolationOrder->1] &/@ Transpose[Table[{Cos@t,Sin@t,t^.1}, {t,0,8 Pi,.1}]];
pltIntFun[d]
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.