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 have the following Code:

No={{1, 2}, {1}};
arrows={{{{0, 0}, {1, 2}}, {{1, 0}, {2, 2}}, {{3, 4}, {1, 1}}}, {{{0, 0}, {1,
 3}}}};
colors={Blue,Blue,Blue};
Animate[Graphics[{Sequence @@ {colors[[#]], 
   Arrow @@ (arrows[[t]][[#]])} & /@ No[[t]]},
 PlotRange -> {{0, 2}, {0, 3}}], {t, Range[1, 2]}]

This does not seem work. It should display 3 arrows at time step 1 and only 1 at t=2... Do you have an idea?

share|improve this question
    
Shouldn't it display 1 arrow at step 2? –  Öskå Jun 2 at 19:43
    
Yes t=1 => 3 arrows and t=2 => 1 Arrow –  user3683367 Jun 2 at 19:47
    
Is that what you are after? –  Öskå Jun 2 at 19:58
    
Yes indeed. Does it not work in the above way? –  user3683367 Jun 2 at 19:59
    
It doesn't work, but Sequence@@ and Arrow@@ is not the easiest way IMO –  Öskå Jun 2 at 20:00

1 Answer 1

up vote 3 down vote accepted

I believe that you should use Thread in your case:

arrows = {{{{0, 0}, {1, 2}}, {{1, 0}, {2, 2}}, {{3, 4}, {1, 1}}}, 
          {{{0, 0}, {1, 3}}}};
colors = Array[#, #2] & @@@ Thread[{{Blue &, Red &}, Length /@ arrows}]
Animate[Graphics[Thread@{colors[[t]], Arrow /@ arrows[[t]]}, 
  ImageSize -> 200, Frame -> True, 
  PlotRange -> {{0, 3}, {0, 4}}], {t, {1, 2}}]

enter image description here

share|improve this answer

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.