1

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?

MaxJ
  • 1,535
  • 1
  • 10
  • 16

1 Answers1

3

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

Öskå
  • 8,587
  • 4
  • 30
  • 49