#/usr/bin/python
from numpy import loadtxt
from matplotlib import pyplot as plt
if __name__=="main":
X = loadtxt("data.txt", skiprows=16)
fig, ax = plt.subplots(1,1,figsize=(15,10))
ph = X[:,4]
Al = X[1,1]
Al1 = X[:,5] * 100. / Al
Al2 = X[:,6] * 100. / Al
Al3 = X[:,7] * 100. / Al
Al4 = X[:,8] * 100. / Al
Al5 = X[:,10] * 13 * 100. / Al
Al6 = X[:,3] * 100. / Al
Al7 = X[:,12] * 100. / Al
ax.plot(ph, Al1, linewidth=2, label=r"Al(OH)${}^{2+}$")
ax.plot(ph, Al2, linewidth=2, label=r"Al(OH)${}_2^+$")
ax.plot(ph, Al3, linewidth=2, label=r"Al(OH)${}_3$")
ax.plot(ph, Al4, linewidth=2, label=r"Al(OH)${}_4^-$")
ax.plot(ph, Al5, linewidth=2, label=r"Al${}_{13}$(OH)${}_{32}^{7+}$")
ax.plot(ph, Al6, linewidth=2, label=r"Al${}^{3+}$")
ax.plot(ph, Al7, linewidth=2, label=r"Al(OH)${}_3$(s)")
ax.set_ylim([0,100])
ax.grid(True)
ax.legend(frameon=False, ncol=3, loc=9)
ax.minorticks_on()
ax.set_ylabel("% formation relative to Al")
ax.set_xlabel("pH")
fig.savefig("Al hydrolysis.svg",bbox_inches="tight", pad_inches=.15)