.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/06_sequences/plot_05_arc_diagram.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` 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_06_sequences_plot_05_arc_diagram.py: Arc diagram of a melody ======================= Wattenberg's arc diagram (2002) joins consecutive occurrences of every repeated subsequence of one long sequence by a semicircle; thickness is the length of the repeat. Beethoven's *Ode to Joy* shows its form at once: the opening phrase returns, the bridge stands apart. .. GENERATED FROM PYTHON SOURCE LINES 10-20 .. code-block:: Python import matplotlib.pyplot as plt import spmviz as sv from spmviz.viz import plot_arc_diagram songs = sv.datasets.load_melodies("song") titles = songs.attributes["song"].tolist() ode = songs[titles.index("Ode to Joy")] plot_arc_diagram([e[0] for e in ode], min_length=3, title="Ode to Joy: repeats of at least three notes") .. image-sg:: /auto_examples/06_sequences/images/sphx_glr_plot_05_arc_diagram_001.png :alt: Ode to Joy: repeats of at least three notes :srcset: /auto_examples/06_sequences/images/sphx_glr_plot_05_arc_diagram_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 21-23 Twinkle, Twinkle, Little Star ----------------------------- .. GENERATED FROM PYTHON SOURCE LINES 23-26 .. code-block:: Python tw = songs[titles.index("Twinkle, Twinkle, Little Star")] plot_arc_diagram([e[0] for e in tw], min_length=3) plt.show() .. image-sg:: /auto_examples/06_sequences/images/sphx_glr_plot_05_arc_diagram_002.png :alt: arc diagram: 6 repeats of length ≥ 3 :srcset: /auto_examples/06_sequences/images/sphx_glr_plot_05_arc_diagram_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.120 seconds) .. _sphx_glr_download_auto_examples_06_sequences_plot_05_arc_diagram.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/ComplexSystemsIntelligence/spmviz/main?urlpath=lab/tree/notebooks/auto_examples/06_sequences/plot_05_arc_diagram.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_05_arc_diagram.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_05_arc_diagram.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_05_arc_diagram.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_