TITLE: Meaning of Rays in Polar Plot of Prime Numbers
QUESTION [219 upvotes]: I recently began experimenting with gnuplot and I quickly made an interesting discovery. I plotted all of the prime numbers beneath 1 million in polar coordinates such that for every prime $p$, $(r,\theta) = (p,p)$. I was not expecting anything in particular, I was simply trying it out. The results are fascinating.
When looking at the primes beneath 30000, a spiral pattern can be seen:

For comparison, here is the same graph with the multiples of 3 and 7 superimposed on it. Primes are in yellow, multiples of 3 and 7 in green and red respectively.

What is really interesting to me, though, is the behavior when the range is increased. Multiples of a given number appear to spiral out in the same pattern into infinity, but the primes begin to form rays in groups of 3 or 4. See below:


Compared to multiples of 3 and 7 again:

Now, I must admit that I am very much a novice mathematician with little experience beyond trigonometry. I am just going into Calculus and Discrete Mathematics this upcoming fall.
I know that there is something called the Prime Number theorem - are these patterns related to it? Are these rays the same phenomenon as the diagonal lines found in Ulam Spirals?
EDIT:
In response to Greg Martin's explanation, I decided to add a couple more graphs. To see why they are relevant, read his answer.
$(r,\theta)=(n,n), n \in  \mathbb{N}$

REPLY [41 votes]: $3$Blue$1$Brown has given a beautiful explanation to the spiral and ray patterns. Please watch his video titled "Why do prime numbers make these spirals?"