
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "auto_examples/plot_1_exp.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_auto_examples_plot_1_exp.py>`
        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_plot_1_exp.py:


Plotting the exponential function
=================================

This example demonstrates how to import a local module and how images are
stacked when two plots are created in one code block. The variable ``N`` from
the example 'Local module' (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.

.. GENERATED FROM PYTHON SOURCE LINES 11-45



.. rst-class:: sphx-glr-horizontal


    *

      .. image-sg:: /auto_examples/images/sphx_glr_plot_1_exp_001.png
         :alt: Exponential function
         :srcset: /auto_examples/images/sphx_glr_plot_1_exp_001.png, /auto_examples/images/sphx_glr_plot_1_exp_001_2_00x.png 2.00x
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /auto_examples/images/sphx_glr_plot_1_exp_002.png
         :alt: Negative exponential function
         :srcset: /auto_examples/images/sphx_glr_plot_1_exp_002.png, /auto_examples/images/sphx_glr_plot_1_exp_002_2_00x.png 2.00x
         :class: sphx-glr-multi-img





.. code-block:: Python


    # Code source: Óscar Nájera
    # License: BSD 3 clause

    import matplotlib.pyplot as plt
    import numpy as np

    # You can use modules local to the example being run, here we import
    # N from local_module
    from local_module import N  # = 100


    def main():
        """Plot exponential functions."""
        x = np.linspace(-1, 2, N)
        y = np.exp(x)

        plt.figure()
        plt.plot(x, y)
        plt.xlabel("$x$")
        plt.ylabel(r"$\exp(x)$")
        plt.title("Exponential function")

        plt.figure()
        plt.plot(x, -np.exp(-x))
        plt.xlabel("$x$")
        plt.ylabel(r"$-\exp(-x)$")
        plt.title("Negative exponential\nfunction")
        # To avoid matplotlib text output
        plt.show()


    if __name__ == "__main__":
        main()


.. _sphx_glr_download_auto_examples_plot_1_exp.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: binder-badge

      .. image:: images/binder_badge_logo.svg
        :target: https://mybinder.org/v2/gh/sphinx-gallery/sphinx-gallery.github.io/master?urlpath=lab/tree/notebooks/auto_examples/plot_1_exp.ipynb
        :alt: Launch binder
        :width: 150 px

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

      :download:`Download Jupyter notebook: plot_1_exp.ipynb <plot_1_exp.ipynb>`

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

      :download:`Download Python source code: plot_1_exp.py <plot_1_exp.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: plot_1_exp.zip <plot_1_exp.zip>`


.. only:: html

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

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