How can Ellingham diagrams be linked to Gibbs energies of formation?
The Ellingham diagram doesn't actually use molar Gibbs energies of formation $\Delta G_\mathrm{f}^\circ$ per se; it is more accurate to say that it uses molar Gibbs energies of reaction $\Delta G_\mathrm{r}^\circ$. The difference is that the formation energy is only relevant to one specific chemical equation, for example:

$$\ce{Ca + 1/2O2 -&gt; CaO} \qquad \qquad \Delta G_\mathrm{r}^\circ = \Delta G_\mathrm{f}^\circ(\ce{CaO})$$

in which the stoichiometric coefficient of CaO is equal to 1.** On the other hand, for any (balanced) equation with any stoichiometric coefficients, it is valid to define a Gibbs energy of reaction:

$$\ce{2Ca + O2 -&gt; 2CaO} \qquad \qquad \Delta G_\mathrm{r}^\circ = 2\times \Delta G_\mathrm{f}^\circ(\ce{CaO})$$

which is related to the energy of formation, but is not the same thing, as evidenced by the factor of 2.

In the Ellingham diagram, every reaction has the same stoichiometric coefficient for $\ce{O2}$, which is typically 1. This is needed to make sure that different reactions are comparable. Let's say, for example, you want to see whether the reaction

$$\ce{C + 2CaO -&gt; CO2 + 2Ca}$$

is feasible. This is done by checking the sign of $\Delta G_\mathrm{r}^\circ$: if it is negative, then the reaction is feasible, and vice versa. The point is that this $\Delta G_\mathrm{r}^\circ$ can be calculated by subtracting two reactions together:

$$\begin{align}
\ce{C + O2 &amp;-&gt; CO2} &amp; \Delta G_\mathrm{r}^\circ &amp;= c_1 = \Delta G_\mathrm{f}^\circ(\ce{CO2}) \\
\ce{2Ca + O2 &amp;-&gt; 2CaO} &amp; \Delta G_\mathrm{r}^\circ &amp;= c_2 = 2 \times \Delta G_\mathrm{f}^\circ(\ce{CaO}) \\ \hline
\ce{C + 2CaO &amp;-&gt; 2Ca + CO2} &amp; \Delta G_\mathrm{r}^\circ &amp;= c_1 - c_2 \\
\end{align}$$

but these two equations add up nicely only if the coefficients of $\ce{O2}$ in both equations are the same. What the Ellingham diagram does is to plot the Gibbs energies of reaction, $c_1$ and $c_2$: if $c_1 &lt; c_2$, then the reaction is feasible. It doesn't plot the Gibbs energies of formation, because comparing those wouldn't tell us anything about the sign of $c_1 - c_2$.

As a final remark, note also that the equation

$$\Delta G_\mathrm{r}^\circ = -RT \ln K$$

holds true for any reaction, whether or not it actually corresponds to a formation reaction.



** Having a stoichiometric coefficient equal to $x$ does not mean the same thing as $x$ moles of the compound are produced in the reaction. The coefficient is purely a mathematical expression which tells us the stoichiometric relationship between different species in the reaction. It does not correspond to a real-life reaction, where a defined quantity of reactant is added to a defined quantity of product. To illustrate this, let's say you go to a lab and mix 0.4 mol of HCl to 0.4 mol of NaOH. You're asked to write a balanced equation for this. You can write

$$\ce{0.4 HCl + 0.4 NaOH -&gt; 0.4 NaCl + 0.4 H2O,}$$

and that would be correct, but it is hardly the only correct possibility: the more conventional 

$$\ce{HCl + NaOH -&gt; NaCl + H2O}$$

is equally correct, even though the stoichiometric coefficients (1 in all cases) do not match up with the actual amount of substance used in the reaction (0.4 mol). Note also that the units are different: stoichiometric coefficients are dimensionless, but amount of substance is measured in moles. The difference is subtle, but one well worth pondering about, as mixing these two up can lead to a lot of misconceptions in thermodynamics.