I want to plot a lot of arrows in a sphere (3D-Plot). That is not a problem with a small number of Arrows; for a few I can do than something like this:

  Graphics3D[{Thickness[Large], Arrowheads[Large],
    Arrow[{{0, 0, 0}, {1, 0, 0}}], Arrow[{{0, 0, 0}, {0, 1, 0}}]}, 
    Axes -> True], 
  SphericalPlot3D[1, {θ, 0, Pi}, {φ, 0, 2*Pi}, 
    PlotStyle -> Opacity[0.2]]]

However, I want do something like a for-loop to plot many Arrows

For[i = 1, i < 11, i++, Arrow[{{0, 0, 0}, {1/i, (1-i)/5, (1-i)/5}}]

I have tried to paste for loop in many places of my graphics code, but without success. How should I build that code?

  • 3
    $\begingroup$ For loops do not create arrays. They repeat an action several times. Try using Table instead. $\endgroup$
    – Searke
    Mar 4, 2013 at 16:47

1 Answer 1


Use Table when you want to create a list of values.

myarrows = Table[Arrow[{{0, 0, 0}, {1/i, (1 - i)/5, (1 - i)/5}}], {i, 1, 10}]


For loops only repeat an evaluation over and over - it doesn't put the result of the evaluations into a list.

  • 1
    $\begingroup$ One might put an Append[] in the middle of the loop, or even use Sow[] and Reap[] in connection with a loop, in order to generate a list. However, there are few scenarios in which either of these is better than using Table[] as you suggest. $\endgroup$ Mar 4, 2013 at 22:36
  • $\begingroup$ Sow and Reap hadn't occurred to me an a quick solution here until just now actually. I feel bad that I don't use it pr functions like it more often. $\endgroup$
    – Searke
    Mar 5, 2013 at 16:57

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.