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

.. only:: html

    .. meta::
        :keywords: codex

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

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

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

.. _sphx_glr_gallery_lines_bars_and_markers_eventplot_demo.py:


==============
Eventplot demo
==============

An `~.axes.Axes.eventplot` showing sequences of events with various line
properties. The plot is shown in both horizontal and vertical orientations.

.. GENERATED FROM PYTHON SOURCE LINES 9-64

.. code-block:: Python


    import matplotlib.pyplot as plt
    import numpy as np

    import matplotlib

    matplotlib.rcParams['font.size'] = 8.0

    # Fixing random state for reproducibility
    np.random.seed(19680801)


    # create random data
    data1 = np.random.random([6, 50])

    # set different colors for each set of positions
    colors1 = [f'C{i}' for i in range(6)]

    # set different line properties for each set of positions
    # note that some overlap
    lineoffsets1 = [-15, -3, 1, 1.5, 6, 10]
    linelengths1 = [5, 2, 1, 1, 3, 1.5]

    fig, axs = plt.subplots(2, 2)

    # create a horizontal plot
    axs[0, 0].eventplot(data1, colors=colors1, lineoffsets=lineoffsets1,
                        linelengths=linelengths1)

    # create a vertical plot
    axs[1, 0].eventplot(data1, colors=colors1, lineoffsets=lineoffsets1,
                        linelengths=linelengths1, orientation='vertical')

    # create another set of random data.
    # the gamma distribution is only used for aesthetic purposes
    data2 = np.random.gamma(4, size=[60, 50])

    # use individual values for the parameters this time
    # these values will be used for all data sets (except lineoffsets2, which
    # sets the increment between each data set in this usage)
    colors2 = 'black'
    lineoffsets2 = 1
    linelengths2 = 1

    # create a horizontal plot
    axs[0, 1].eventplot(data2, colors=colors2, lineoffsets=lineoffsets2,
                        linelengths=linelengths2)


    # create a vertical plot
    axs[1, 1].eventplot(data2, colors=colors2, lineoffsets=lineoffsets2,
                        linelengths=linelengths2, orientation='vertical')

    plt.show()




.. image-sg:: /gallery/lines_bars_and_markers/images/sphx_glr_eventplot_demo_001.png
   :alt: eventplot demo
   :srcset: /gallery/lines_bars_and_markers/images/sphx_glr_eventplot_demo_001.png, /gallery/lines_bars_and_markers/images/sphx_glr_eventplot_demo_001_2_00x.png 2.00x
   :class: sphx-glr-single-img





.. GENERATED FROM PYTHON SOURCE LINES 65-70

.. tags::

   plot-type: eventplot
   level: beginner
   purpose: showcase


.. _sphx_glr_download_gallery_lines_bars_and_markers_eventplot_demo.py:

.. only:: html

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

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

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

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

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

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

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


.. only:: html

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

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