Including plots is easy. The following doc-string code:
.. plot:: import numpy as np import matplotlib.pyplot as plt x = np.linspace(0,2, 1000) plt.figure() plt.plot(x, np.sqrt(x), label = r"Skiing: $\sqrt{x}$") plt.plot(x, x**2, label = r"Snowboarding: $x^2$") plt.title("Learning Curves for Snowboarding and Skiing") plt.xlabel("Time") ; plt.ylabel("Skill") plt.legend(loc='upper left') plt.show()gives
(Source code, png, hires.png, pdf)
In essence, this enables not only comments about the code, but also comments about the science and research behind your code, to be interwoven into the coding file.
Nice, I didn't know that you could integrate matplotlib with Sphinx.