.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/06_sequences/plot_04_sequence_logo.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_04_sequence_logo.py: Sequence logos ============== Borrowed from bioinformatics (Schneider & Stephens, 1990): every column stacks the events seen at a position relative to an anchor, letter heights proportional to their probability times the information content of the column (:math:`\log_2 K - H`). Conserved steps are tall, variable steps are low. .. GENERATED FROM PYTHON SOURCE LINES 10-18 .. code-block:: Python import matplotlib.pyplot as plt import spmviz as sv from spmviz.viz import plot_sequence_logo shop = sv.datasets.make_customer_journeys(1000, random_state=0) plot_sequence_logo(shop, anchor="cart", before=3, after=4) .. image-sg:: /auto_examples/06_sequences/images/sphx_glr_plot_04_sequence_logo_001.png :alt: sequence logo around cart :srcset: /auto_examples/06_sequences/images/sphx_glr_plot_04_sequence_logo_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 19-21 The openings of melodies ------------------------ .. GENERATED FROM PYTHON SOURCE LINES 21-24 .. code-block:: Python songs = sv.datasets.load_melodies("phrase") plot_sequence_logo(songs, before=0, after=6, info=False, title="first notes of the phrases (probabilities)") plt.show() .. image-sg:: /auto_examples/06_sequences/images/sphx_glr_plot_04_sequence_logo_002.png :alt: first notes of the phrases (probabilities) :srcset: /auto_examples/06_sequences/images/sphx_glr_plot_04_sequence_logo_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.182 seconds) .. _sphx_glr_download_auto_examples_06_sequences_plot_04_sequence_logo.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_04_sequence_logo.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_04_sequence_logo.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_04_sequence_logo.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_04_sequence_logo.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_