Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
For loops do not create arrays. They repeat an action several times. Try using Table instead. – Searke Mar 4 '13 at 16:47
up vote 5 down vote accepted

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.

share|improve this answer
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. – Michael Stern Mar 4 '13 at 22:36
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. – Searke Mar 5 '13 at 16:57

Your Answer


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.