.. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code or to run this example in your browser via Binder .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_ex3.py: Tertiary example - Plotting sin3 =================================== This is a general example demonstrating a Matplotlib plot output, embedded rST, the use of math notation and cross-linking to other examples. It would be useful to compare with the output below. .. math:: x \rightarrow \sin(x) Here the function :math:`\sin` is evaluated at each point the variable :math:`x` is defined. .. code-block:: default import numpy as np import matplotlib.pyplot as plt x = np.linspace(0, 2 * np.pi, 100) y = np.sin(x) plt.plot(x, y) plt.xlabel('$x$') plt.ylabel('$\sin(x)$') # To avoid matplotlib text output plt.show() .. image:: /auto_examples/images/sphx_glr_ex3_001.png :class: sphx-glr-single-img To include embedded rST, use a line of >= 20 ``#``'s or ``#%%`` between your rST and your. This separates your example into distinct text and code blocks. You can continue writing code below the embedded rST text block: .. code-block:: default print('This example shows a sin plot!') .. rst-class:: sphx-glr-script-out Out: .. code-block:: none This example shows a sin plot! .. code-block:: default from py_qs_example.mymodule import ExampleClass, example_function, less_important_function ec = ExampleClass(5) ec .. rst-class:: sphx-glr-script-out Out: .. code-block:: none example .. code-block:: default output = example_function(ec, '_test') output .. rst-class:: sphx-glr-script-out Out: .. code-block:: none 'example_test' LaTeX syntax in the text blocks does not require backslashes to be escaped: .. math:: \sin Cross referencing ^^^^^^^^^^^^^^^^^ You can refer to an example from any part of the documentation, including from other examples. Sphinx-Gallery automatically creates reference labels for each example. The label consists of the ``.py`` file name, prefixed with ``sphx_glr_`` and the name of the folder(s) the example is in. In this case, the example we want to cross-reference is in ``auto_examples`` (the ``gallery_dirs``; see .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.212 seconds) .. _sphx_glr_download_auto_examples_ex3.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: binder-badge .. image:: https://mybinder.org/badge_logo.svg :target: https://mybinder.org/v2/gh/nickderobertis/pypi-sphinx-quickstart/gh-pages?urlpath=lab/tree/notebooks/auto_examples/ex3.ipynb :width: 150 px .. container:: sphx-glr-download :download:`Download Python source code: ex3.py ` .. container:: sphx-glr-download :download:`Download Jupyter notebook: ex3.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_