I needed to be able to generate simulation plots for a sphinx document but I didn't want to have to generate the plots separately and then include them manually. I wanted the simulations done from within sphinx so that they would be automatically included when building the document. The key to this is to add the following to the list of extensions in the sphinx conf.py file:
extensions.append ('matplotlib.sphinxext.plot_directive')
To use it in a sphinx document use the plot directive, for example:
.. plot::
:include-source:
import tellurium as te
r = te.loada ('''A -> B; k1*A; k1=0.1; A = 10''')
m = r.simulate (0, 40, 100)
r.plot()
It assumes you have matplotlib installed in your python setup (I am using Windows 10, Python 3.11). Further information can be found here:
https://matplotlib.org/stable/api/sphinxext_plot_directive_api.html
No comments:
Post a Comment