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

.. only:: html

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

        :ref:`Go to the end <sphx_glr_download_gallery_mpl-sliders-same-figure.py>`
        to download the full example code

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_gallery_mpl-sliders-same-figure.py:


=====================================================
Matplotlib Sliders without a separate Controls Figure
=====================================================

Demonstration of how to provide a matplotlib slider to prevent
the creation of a separate controls figure.

.. GENERATED FROM PYTHON SOURCE LINES 9-28



.. image-sg:: /gallery/images/sphx_glr_mpl-sliders-same-figure_001.gif
   :alt: mpl sliders same figure
   :srcset: /gallery/images/sphx_glr_mpl-sliders-same-figure_001.gif
   :class: sphx-glr-single-img





.. code-block:: default

    import matplotlib.pyplot as plt
    import numpy as np
    from matplotlib.widgets import Slider

    from mpl_interactions import ipyplot as iplt

    fig, ax = plt.subplots()
    plt.subplots_adjust(bottom=0.25)
    x = np.linspace(0, 2 * np.pi, 200)


    def f(x, freq):
        return np.sin(x * freq)


    axfreq = plt.axes([0.25, 0.1, 0.65, 0.03])
    slider = Slider(axfreq, label="freq", valmin=0.05, valmax=10)
    controls = iplt.plot(x, f, freq=slider, ax=ax)
    plt.show()


.. rst-class:: sphx-glr-timing

   **Total running time of the script:** (0 minutes 28.183 seconds)


.. _sphx_glr_download_gallery_mpl-sliders-same-figure.py:

.. only:: html

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




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

      :download:`Download Python source code: mpl-sliders-same-figure.py <mpl-sliders-same-figure.py>`

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

      :download:`Download Jupyter notebook: mpl-sliders-same-figure.ipynb <mpl-sliders-same-figure.ipynb>`


.. only:: html

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

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