:orphan:

.. _examples-index:

Basics Gallery with Matplotlib
==============================

This page consists of the 'Basics Gallery with matplotlib' and a sub-gallery
(aka subsection), 'No image output examples'. This sub-gallery is generated from a
sub-directory within the general examples directory. The file structure of
this gallery looks like this:

.. code-block:: none

    examples/           # base 'Basics Gallery with Matplotlib' directory
    ├── GALLERY_HEADER.rst
    ├── <.py files>
    └── no_output/      # generates the 'No image output examples' sub-gallery
        ├── GALLERY_HEADER.rst
        └── <.py files>

.. _general_examples:

General examples
----------------

This gallery consists of introductory examples and examples demonstrating
specific features of Sphinx-Gallery.

.. raw:: html

.. raw:: html

    <div class="sphx-glr-thumbnails">

.. thumbnail-parent-div-open

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This example demonstrates how local modules can be imported. This module is imported in the example &#x27;Plotting the exponential function&#x27; (``plot_exp.py``).">

.. only:: html

  .. image:: /auto_examples/images/thumb/sphx_glr_local_module_thumb.png
    :alt:

  :doc:`/auto_examples/local_module`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Local module</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" data-sgtags='["matplotlib", "line-plot"]' tooltip="This is a general example demonstrating a Matplotlib plot output, embedded reST, the use of math notation and cross-linking to other examples. It would be useful to compare the source Python file &lt;plot_0_sin.py&gt; with the output below.">

.. only:: html

  .. image:: /auto_examples/images/thumb/sphx_glr_plot_0_sin_thumb.png
    :alt:

  :doc:`/auto_examples/plot_0_sin`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Introductory example - Plotting sin</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" data-sgtags='["matplotlib", "line-plot", "🚀", "折れ線グラフ"]' tooltip="This example demonstrates how to import a local module and how images are stacked when two plots are created in one code block (see the plot_9_multi_image_separate example for information on controlling this behaviour). The variable N from the example &#x27;Local module&#x27; (file local_module.py) is imported in the code below. Further, note that when there is only one code block in an example, the output appears before the code block.">

.. only:: html

  .. image:: /auto_examples/images/thumb/sphx_glr_plot_1_exp_thumb.png
    :alt:

  :doc:`/auto_examples/plot_1_exp`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Plotting the exponential function</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" data-sgtags='["matplotlib", "line-plot", "seaborn"]' tooltip="This example demonstrates a Seaborn plot. Figures produced Matplotlib and by any package that is based on Matplotlib (e.g., Seaborn), will be captured by default. See image_scrapers for details.">

.. only:: html

  .. image:: /auto_examples/images/thumb/sphx_glr_plot_2_seaborn_thumb.png
    :alt:

  :doc:`/auto_examples/plot_2_seaborn`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Seaborn example</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" data-sgtags='["matplotlib", "repr"]' tooltip="This example demonstrates how the configuration capture_repr (capture_repr) works. The default capture_repr setting is capture_repr: (&#x27;_repr_html_&#x27;, &#x27;__repr__&#x27;) and was used when building the Sphinx-Gallery documentation. The output that is captured with this setting is demonstrated in this example. Differences in outputs that would be captured with other capture_repr settings is also explained.">

.. only:: html

  .. image:: /auto_examples/images/thumb/sphx_glr_plot_3_capture_repr_thumb.png
    :alt:

  :doc:`/auto_examples/plot_3_capture_repr`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Capturing output representations</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" data-sgtags='["matplotlib", "line-plot", "thumbnails"]' tooltip="This example demonstrates how to choose the figure that is displayed as the thumbnail, if the example generates more than one figure. This is done by specifying the keyword-value pair sphinx_gallery_thumbnail_number = &lt;fig number&gt; as a comment somewhere below the docstring in the example file. In this example, we specify that we wish for the second figure to be the thumbnail.">

.. only:: html

  .. image:: /auto_examples/images/thumb/sphx_glr_plot_4_choose_thumbnail_thumb.png
    :alt:

  :doc:`/auto_examples/plot_4_choose_thumbnail`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Choosing the thumbnail figure</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" data-sgtags='["matplotlib", "line-plot", "multiple-figures"]' tooltip="This example demonstrates how to provide a figure that is displayed as the thumbnail. This is done by specifying the keyword-value pair sphinx_gallery_thumbnail_path = &#x27;fig path&#x27; as a comment somewhere below the docstring in the example file. In this example, we specify that we wish the figure demo.png in the folder _static to be used for the thumbnail. Note, the path to the image should be relative to the conf.py.">

.. only:: html

  .. image:: /auto_examples/images/thumb/sphx_glr_plot_4b_provide_thumbnail_thumb.png
    :alt:

  :doc:`/auto_examples/plot_4b_provide_thumbnail`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Providing a figure for the thumbnail image</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" data-sgtags='["matplotlib", "line-plot", "unicode"]' tooltip="This example demonstrates how to include non-ASCII characters, mostly emoji 🎉 to stress test the build and test environments that parse the example files.">

.. only:: html

  .. image:: /auto_examples/images/thumb/sphx_glr_plot_5_unicode_everywhere_thumb.png
    :alt:

  :doc:`/auto_examples/plot_5_unicode_everywhere`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Using Unicode everywhere 🤗</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" data-sgtags='["matplotlib", "demo"]' tooltip="This demonstrates how Sphinx-Gallery identifies when">

.. only:: html

  .. image:: /auto_examples/images/thumb/sphx_glr_plot_6_function_identifier_thumb.png
    :alt:

  :doc:`/auto_examples/plot_6_function_identifier`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Identifying function names in a script</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" data-sgtags='["argv"]' tooltip="This example demonstrates the use of sys.argv in example .py files.">

.. only:: html

  .. image:: /auto_examples/images/thumb/sphx_glr_plot_7_sys_argv_thumb.png
    :alt:

  :doc:`/auto_examples/plot_7_sys_argv`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Using sys.argv in examples</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" data-sgtags='["matplotlib", "line-plot", "animation"]' tooltip="Show a Matplotlib animation, which should end up nicely embedded below.">

.. only:: html

  .. image:: /auto_examples/images/thumb/sphx_glr_plot_8_animations_thumb.gif
    :alt:

  :doc:`/auto_examples/plot_8_animations`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Matplotlib animation support</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" data-sgtags='["matplotlib", "image", "split-plots"]' tooltip="There are two config options to control this behaviour:">

.. only:: html

  .. image:: /auto_examples/images/thumb/sphx_glr_plot_9_multi_image_separate_thumb.png
    :alt:

  :doc:`/auto_examples/plot_9_multi_image_separate`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Force plots to be displayed on separate lines</div>
    </div>


.. thumbnail-parent-div-close

.. raw:: html

    </div>


.. toctree::
   :hidden:

   /auto_examples/local_module
   /auto_examples/plot_0_sin
   /auto_examples/plot_1_exp
   /auto_examples/plot_2_seaborn
   /auto_examples/plot_3_capture_repr
   /auto_examples/plot_4_choose_thumbnail
   /auto_examples/plot_4b_provide_thumbnail
   /auto_examples/plot_5_unicode_everywhere
   /auto_examples/plot_6_function_identifier
   /auto_examples/plot_7_sys_argv
   /auto_examples/plot_8_animations
   /auto_examples/plot_9_multi_image_separate

No image output examples
------------------------

This section gathers examples which don't produce any figures. Some examples
only output to standard output, others demonstrate how Sphinx-Gallery handles
examples with errors.

.. raw:: html

.. raw:: html

    <div class="sphx-glr-thumbnails">

.. thumbnail-parent-div-open

.. raw:: html

    <div class="sphx-glr-thumbcontainer" data-sgtags='["just-code"]' tooltip="This demonstrates an example .py file that is not executed when gallery is generated (see build_pattern) but nevertheless gets included as an example. Note that no output is capture as this file is not executed.">

.. only:: html

  .. image:: /auto_examples/no_output/images/thumb/sphx_glr_just_code_thumb.png
    :alt:

  :doc:`/auto_examples/no_output/just_code`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">A short Python script</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This example demonstrates a code block that raises an error and how any code blocks that follow are not executed.">

.. only:: html

  .. image:: /auto_examples/no_output/images/thumb/sphx_glr_plot_raise_thumb.png
    :alt:

  :doc:`/auto_examples/no_output/plot_raise`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Example that fails to execute</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="By default, examples with code blocks that raise an error will have the broken image stamp as their gallery thumbnail. However, this may not be desired, e.g. if only part of the example is expected to fail and it should not look like the entire example fails.">

.. only:: html

  .. image:: /auto_examples/no_output/images/thumb/sphx_glr_plot_raise_thumbnail_thumb.png
    :alt:

  :doc:`/auto_examples/no_output/plot_raise_thumbnail`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Example that fails to execute (with normal thumbnail behaviour)</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This example captures the standard output and includes it in the example. If output is too long it becomes automatically framed into a text area.">

.. only:: html

  .. image:: /auto_examples/no_output/images/thumb/sphx_glr_plot_strings_thumb.png
    :alt:

  :doc:`/auto_examples/no_output/plot_strings`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Constrained Text output frame</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Example script with invalid Python syntax ">

.. only:: html

  .. image:: /auto_examples/no_output/images/thumb/sphx_glr_plot_syntaxerror_thumb.png
    :alt:

  :doc:`/auto_examples/no_output/plot_syntaxerror`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">SyntaxError</div>
    </div>


.. thumbnail-parent-div-close

.. raw:: html

    </div>


.. toctree::
   :hidden:
   :includehidden:


   /auto_examples/no_output/index.rst


.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-gallery

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download all examples in Python source code: auto_examples_python.zip </auto_examples/auto_examples_python.zip>`

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download all examples in Jupyter notebooks: auto_examples_jupyter.zip </auto_examples/auto_examples_jupyter.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
