a rainbow comes from spreading all the white light the (light containing all colors) from the sun.
The colors in the spectrum of an atom , Comes from the energy given up by transitions of electrons from one to another . The only colors are those whose photons have energies equal the same amount of energy changes that electrons in a particular atom can undergo.