From: <jd...@us...> - 2009-08-11 18:01:10
|
Revision: 7472 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7472&view=rev Author: jdh2358 Date: 2009-08-11 18:01:00 +0000 (Tue, 11 Aug 2009) Log Message: ----------- more examples on how to use the extensions Modified Paths: -------------- trunk/sampledoc_tut/extensions.rst Modified: trunk/sampledoc_tut/extensions.rst =================================================================== --- trunk/sampledoc_tut/extensions.rst 2009-08-11 12:41:05 UTC (rev 7471) +++ trunk/sampledoc_tut/extensions.rst 2009-08-11 18:01:00 UTC (rev 7472) @@ -61,8 +61,22 @@ ================ Michael Droettboom contributed a sphinx extension which does pygments -syntax highlighting on ipython sessions +syntax highlighting on ipython sessions. Just use ipython as the +language in the sourcecode directive:: + .. sourcecode:: ipython + + In [69]: lines = plot([1,2,3]) + + In [70]: setp(lines) + alpha: float + animated: [True | False] + antialiased or aa: [True | False] + ...snip + + +and you will get the syntax highlighted output below. + .. sourcecode:: ipython In [69]: lines = plot([1,2,3]) @@ -88,6 +102,19 @@ W^{3\beta}_{\delta_1 \rho_1 \sigma_2} = U^{3\beta}_{\delta_1 \rho_1} + \frac{1}{8 \pi 2} \int^{\alpha_2}_{\alpha_2} d \alpha^\prime_2 \left[\frac{ U^{2\beta}_{\delta_1 \rho_1} - \alpha^\prime_2U^{1\beta}_{\rho_1 \sigma_2} }{U^{0\beta}_{\rho_1 \sigma_2}}\right] +To include math in your document, just use the math directive; here is +a simpler equation:: + + .. math:: + + W^{3\beta}_{\delta_1 \rho_1 \sigma_2} \approx U^{3\beta}_{\delta_1 \rho_1} + +which is rendered as + +.. math:: + + W^{3\beta}_{\delta_1 \rho_1 \sigma_2} \approx U^{3\beta}_{\delta_1 \rho_1} + This documentation framework includes a Sphinx extension, :file:`sphinxext/mathmpl.py`, that uses matplotlib to render math equations when generating HTML, and LaTeX itself when generating a @@ -108,7 +135,7 @@ All three of these options for math are designed to behave in the same way. -.. _emacs-helpers: +.. _pyplots: Inserting matplotlib plots ========================== @@ -128,6 +155,35 @@ .. plot:: pyplots/ellipses.py :include-source: + +You can also inline simple plots, and the code will be executed at +documentation build time and the figure inserted into your docs; the +following code:: + + .. plot:: + + import matplotlib.pyplot as plt + import numpy as np + x = np.random.randn(1000) + plt.hist( x, 20) + plt.grid() + plt.title(r'Normal: $\mu=%.2f, \sigma=%.2f$'%(x.mean(), x.std())) + plt.show() + +produces this output: + +.. plot:: + + import matplotlib.pyplot as plt + import numpy as np + x = np.random.randn(1000) + plt.hist( x, 20) + plt.grid() + plt.title(r'Normal: $\mu=%.2f, \sigma=%.2f$'%(x.mean(), x.std())) + plt.show() + + + Inheritance diagrams ==================== This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |