1
$\begingroup$

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?

$\endgroup$
6
  • $\begingroup$ Shouldn't it display 1 arrow at step 2? $\endgroup$
    – Öskå
    Jun 2, 2014 at 19:43
  • $\begingroup$ Yes t=1 => 3 arrows and t=2 => 1 Arrow $\endgroup$
    – MaxJ
    Jun 2, 2014 at 19:47
  • $\begingroup$ Is that what you are after? $\endgroup$
    – Öskå
    Jun 2, 2014 at 19:58
  • $\begingroup$ Yes indeed. Does it not work in the above way? $\endgroup$
    – MaxJ
    Jun 2, 2014 at 19:59
  • $\begingroup$ It doesn't work, but Sequence@@ and Arrow@@ is not the easiest way IMO $\endgroup$
    – Öskå
    Jun 2, 2014 at 20:00

1 Answer 1

3
$\begingroup$

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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