예제 #1
0
    of equal to 7.
The phenolphthalein reacts with NaOH to change to pink. As the colour changes from pink to transparent, the colour
    would change before pH of seven. The whole line is decreasing, since it meets the end point first, then the
    equivalent point. (First change the colour, then neutralise)
"""

import matplotlib.pyplot as plt
from mpl_toolkits.axisartist import SubplotZero
import numpy as np
"""
a bug found! in SubplotZero, by saying xlabel and ylabel, xzeros and yzeros set the all axis label as xlabel
"""

fig = plt.figure()
ax = SubplotZero(fig, 111)
ax.set_title("Add HCl to NaOH Solution\npH of NaOH Solution")
fig.add_subplot(ax)

for direction in ["xzero", "yzero"]:
    ax.axis[direction].set_axisline_style("-|>")
    ax.axis[direction].set_visible(True)

for direction in ["top", "bottom", "left", "right"]:
    ax.axis[direction].set_visible(False)

y = np.linspace(0, 20)
x = -(((y - 8)**5) / 1000) + 10
plt.plot(x, y)
plt.xlim(0, 25)
plt.ylim(0, 15)
plt.gca().set_aspect('equal')
예제 #2
0
"""
pH.py
sketch acid and base pH formula
# from mpl.toolkits.axisartist import Subplotzero
# ax.axis[direction].set_axisline_style("-|>")
# ax.axis[direction].set_visible(True||False)

"""

from matplotlib import pyplot as plt
from mpl_toolkits.axisartist import SubplotZero
import numpy as np

fig = plt.figure()
ax = SubplotZero(fig, 111)
ax.set_title("pH Formula")
fig.add_subplot(ax)

for direction in ["xzero", "yzero"]:
    ax.axis[direction].set_axisline_style("-|>")
    ax.axis[direction].set_visible(True)

for direction in ["top", "bottom", "left", "right"]:
    ax.axis[direction].set_visible(False)

# log a(n) n > 0
x = np.linspace(0.01, 20, 2000)
y = np.log10(x)

plt.plot(x, -y, color="m", label="acid pH = -log{}{}[H{}O{}]".format("\N{SUBSCRIPT ONE}",
                                                                     "\N{SUBSCRIPT ZERO}",