X-ray crystallography is the most difficult of the techniques so far described to grasp, as it is intensely mathematical. What we would really like to do with X-rays is to take pictures of atoms, like we can take pictures of bigger things with visible light. The reason we must use X-rays is that to 'see' something with light, the light must have a wavelength similar to
(or smaller than) the size of the thing we are looking at. X-rays fit the bill here (visible light is far too big to see atoms), but they unfortunately cannot be focussed by any current technique. Hence we must rely on making diffraction patterns from beautifully ordered piles of molecules (crystals), rather than looking at the molecules directly. Crystallisation of the compound of interets is the primary problem in X-ray crystallography: making perfect crystals is rather fraught. Once we have a nice crystal of the compound (e.g. a protein), we illuminate it with X-rays and collect the diffracted X-rays on a photographic film, to form a diffraction pattern, like the one below.
The diffraction patterns can be mathematically transformed back into electron density maps of the molecules in the crystals by Fourier transform techniques we won't go into here. A further problem of X-ray diffraction is that it relies on the size of the atoms, and hydrogen is too small to show up
(Hydrogen makes up 63% of the body, so that's an important omission = but you can mostly work out where the Hs should be), hence when we 'join the dots' in our electron density map, we get something akin to a line-bond notation of the compound we have 'photographed'.
Haem electron density map: note the 'dot-to-dot' and missing hydrogens.
Left, top view of unbound haem; right, side-on view on haem coordinating to two Histidines from whatever protein the haem is bound in. Carbons yellow, oxygens red, nitrogens blue, the iron atom is shown in white.