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

.. only:: html

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

        :ref:`Go to the end <sphx_glr_download_gallery_plotting_spectrogram.py>`
        to download the full example code.

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

.. _sphx_glr_gallery_plotting_spectrogram.py:


Spectrogram and Line Plot
=========================

A spectrogram and waveform plot of 1D data.

.. GENERATED FROM PYTHON SOURCE LINES 11-30



.. image-sg:: /gallery/plotting/images/sphx_glr_spectrogram_001.png
   :alt: spectrogram
   :srcset: /gallery/plotting/images/sphx_glr_spectrogram_001.png
   :class: sphx-glr-single-img





.. code-block:: Python


    import numpy as np

    from vispy import plot as vp

    # Create a logarithmic chirp
    fs = 1000.
    N = 10000
    t = np.arange(N) / float(fs)
    f0, f1 = 1., 500.
    phase = (t[-1] / np.log(f1 / f0)) * f0 * (pow(f1 / f0, t / t[-1]) - 1.0)
    data = np.cos(2 * np.pi * phase)

    fig = vp.Fig(size=(800, 400), show=False)
    fig[0:2, 0].spectrogram(data, fs=fs, clim=(-100, -20))
    fig[2, 0].plot(np.array((t, data)).T, marker_size=0)

    if __name__ == '__main__':
        fig.show(run=True)


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

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


.. _sphx_glr_download_gallery_plotting_spectrogram.py:

.. only:: html

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

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

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

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

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

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

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


.. only:: html

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

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