fig = plt.figure(figsize=(8,8), dpi=150)
#normal pH
plt.plot([7.4,7.4],[0,60],'--',color='silver')
#normal bicarb
plt.plot([6.8,8.0],[24,24],'--',color='silver')
#buffer line
plt.plot([6.8,8.0],[34,15],'--',color='silver')
plt.text(7.9,15, 'Buffer\nLine', fontsize=10, color="gray")
plt.xticks(xpH)
plt.yticks(np.arange(0,61.0,step=5))
plt.grid(color='whitesmoke',which='major', linestyle='-', linewidth=0.5)
for pCO2 in yCO2[::-1]:
yBicarb = calcBicarb(pCO2,xh)
plt.plot(xpH, yBicarb, label="CO2=%s" %(pCO2))
background_alpha = 1
#plot respiratory acidosis
plt.fill([6.8,7.4,7.4,6.8],[60,60,24.5,34],color="lightcoral",alpha=background_alpha)
plt.text(7.07, 55, 'Respiratory\nAcidosis', fontsize=15, color="white")
plt.text(7.0,32, 'Acute', fontsize=15, color="white")
plt.text(7.22,40, 'Chronic', fontsize=15, color="white")
#plot respiratory alkalosis
plt.fill([7.4,7.4,8.0,8.0],[0,24.5,15,0],color="lightgreen",alpha=background_alpha)
plt.text(7.6,2, 'Respiratory\nAlkalosis', fontsize=15, color="white")
plt.text(7.8,10, 'Acute', fontsize=15, color="white")
plt.text(7.45,10, 'Chronic', fontsize=15, color="white")
#plot Metabolic alkalosis
plt.fill([7.4,7.4, 7.5, 7.6, 7.7, 7.8, 7.9, 8.],[60,24.5, 30.,38,48.,60.,74.,96.],color="lightblue",alpha=background_alpha)
plt.text(7.5, 55, 'Metabolic\nAlkalosis', fontsize=15, color="white")
#plot Metabolic acidosis
plt.fill([6.8, 6.9, 7., 7.1, 7.2, 7.3 ,7.4,7.4, 6.8],[6.,7.6,9.6, 12, 15,19,24.5,0,0],color="violet",alpha=background_alpha)
plt.text(6.9,2, 'Metabolic\nAcidosis', fontsize=15, color="white")
plt.legend()
plt.xlabel('pH')
plt.ylabel('Bicarbonate (HCO3-)')
plt.title('Acid-Base Nomogram (by Fpnotebook.com)')
plt.axis([6.8,8.0,0,60])
plt.savefig("acidBaseNomogram.svg")