Why is the relationship between atomic number and density not linear? What are the factors that affect the density of an atom?
 A: Examine the densities of di-atomic gaseous elements ($\text{H}_2$, $\text{N}_2$, $\text{O}_2$) at STP. Compare to their respective atomic weights. Also look at the densities of the noble gasses at STP. Again, note how they scale roughly with the atomic weight.
By choosing materials that are more or less ideal gases I've isolated the system from the effects of almost all the messy chemistry that cause other states of matter to not scale (the exception is the question of how many atoms go into each molecule which is why I separated my examples into two groups).

For the condensed states of mater (liquid and solids) the chemistry involves itself more strongly in terms of inter-molecular forces. This is most evident in crystalline solids as the geometry of the crystal sets the number density of atoms in terms of both the length of inter-atomic bonds and the symmetries of the crystalline structure.
A: At an atomic scale, there are two things that go into the density, which is $\rho=\frac{\mbox{mass}}{\mbox{volume}}$. First, we have the number density, which is  $n=\frac{\mbox{number of atoms}}{\mbox{volume}}$. Then we also have the mass per atom, $\mu=\frac{\mbox{mass}}{\mbox{atom}}$. It is easy to see by combining these equations that the density is then $\rho=n\mu$ - it depends on both number density and atomic weights.
While the mass per atom, $\mu$, goes up linearly (very roughly speaking) as you go up in atomic number, the number density does not go up linearly. This is because interactions between the actual atoms cause them to cluster closer together, so you get a higher value of $n$ in the equation above for some atoms, but a much lower one for others. For example, in that graph you linked to above:

Those spikes in density are caused by much higher number density, which is in turn caused by metallic attractions between the atoms. The deepest valleys are the noble gases which have virtually no mutual attractions whatsoever.
A: I think your argument is assuming that the density of a material is due to the density of the atoms and I'll try to answer it as such.
The answer is largely because of chemistry.
For example, the noble gasses all have low density because they're gasses. They're gasses because they don't combine chemically. They don't combine chemically because all their atomic orbitals are already filled. And their atomic orbitals are filled because they have just the "right" number of electrons. On the other hand, the alkali metals all have a single extra electron. They all form metals and so are considerably denser than the noble gasses right next to them in atomic number.
