.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/ms_bokeh/plot_spectrum_ms_bokeh.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end <sphx_glr_download_gallery_ms_bokeh_plot_spectrum_ms_bokeh.py>` to download the full example code. or to run this example in your browser via Binder .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_ms_bokeh_plot_spectrum_ms_bokeh.py: Spectrum ms_bokeh ======================================= This example shows a spectrum. We can add the ion_annotation and sequence annotation by specifying these columns. .. GENERATED FROM PYTHON SOURCE LINES 8-31 .. bokeh-plot:: :source-position: none from bokeh.plotting import show import pandas as pd from io import StringIO import requests pd.options.plotting.backend = "ms_bokeh" # download the file for example plotting url = ( "https://github.com/OpenMS/pyopenms_viz/releases/download/v0.1.5/TestSpectrumDf.tsv" ) response = requests.get(url) response.raise_for_status() # Check for any HTTP errors df = pd.read_csv(StringIO(response.text), sep="\t") # mirror a reference spectrum with ion and sequence annoations df.plot( x="mz", y="intensity", kind="spectrum", ion_annotation="ion_annotation", sequence_annotation="sequence", ) .. raw:: html <div class="output_subarea output_html rendered_html output_result"> <div style="display: table;"><div style="display: table-row;"><div style="display: table-cell;"><b title="bokeh.plotting._figure.figure">figure</b>(</div><div style="display: table-cell;">id = 'p1658', <span id="p1800" style="cursor: pointer;">…)</span></div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">above = [],</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">align = 'auto',</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">aspect_ratio = None,</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">aspect_scale = 1,</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">attribution = [],</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">background_fill_alpha = 1.0,</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">background_fill_color = '#ffffff',</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">below = [LinearAxis(id='p1670', ...)],</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">border_fill_alpha = 1.0,</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">border_fill_color = '#ffffff',</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">center = [Grid(id='p1674', ...), Grid(id='p1679', ...), Label(id='p1773', ...), Label(id='p1774', ...), Label(id='p1775', ...), Label(id='p1776', ...), Label(id='p1777', ...), Span(id='p1778', ...)],</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">context_menu = None,</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">css_classes = [],</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">css_variables = {},</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">disabled = False,</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">elements = [],</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">extra_x_ranges = {},</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">extra_x_scales = {},</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">extra_y_ranges = {},</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">extra_y_scales = {},</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">flow_mode = 'block',</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">frame_align = True,</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">frame_height = None,</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">frame_width = None,</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">height = 500,</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">height_policy = 'auto',</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">hidpi = True,</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">hold_render = False,</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">js_event_callbacks = {},</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">js_property_callbacks = {},</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">left = [LinearAxis(id='p1675', ...)],</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">lod_factor = 10,</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">lod_interval = 300,</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">lod_threshold = 2000,</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">lod_timeout = 500,</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">margin = None,</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">match_aspect = False,</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">max_height = None,</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">max_width = None,</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">min_border = 0,</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">min_border_bottom = None,</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">min_border_left = None,</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">min_border_right = None,</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">min_border_top = None,</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">min_height = None,</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">min_width = None,</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">name = None,</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">outline_line_alpha = 1.0,</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">outline_line_cap = 'butt',</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">outline_line_color = '#e5e5e5',</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">outline_line_dash = [],</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">outline_line_dash_offset = 0,</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">outline_line_join = 'bevel',</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">outline_line_width = 1,</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">output_backend = 'canvas',</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">renderers = [GlyphRenderer(id='p1702', ...), GlyphRenderer(id='p1714', ...), GlyphRenderer(id='p1726', ...), GlyphRenderer(id='p1738', ...), GlyphRenderer(id='p1750', ...), GlyphRenderer(id='p1762', ...)],</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">reset_policy = 'standard',</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">resizable = False,</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">right = [Legend(id='p1765', ...)],</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">sizing_mode = None,</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">styles = {},</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">stylesheets = [],</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">subscribed_events = PropertyValueSet(),</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">syncable = True,</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">tags = [],</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">title = Title(id='p1661', ...),</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">title_location = 'above',</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">toolbar = Toolbar(id='p1667', ...),</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">toolbar_inner = False,</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">toolbar_location = 'above',</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">toolbar_sticky = True,</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">visible = True,</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">width = 500,</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">width_policy = 'auto',</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">x_range = Range1d(id='p1779', ...),</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">x_scale = LinearScale(id='p1668', ...),</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">y_range = Range1d(id='p1780', ...),</div></div><div class="p1799" style="display: none;"><div style="display: table-cell;"></div><div style="display: table-cell;">y_scale = LinearScale(id='p1669', ...))</div></div></div> <script> (function() { let expanded = false; const ellipsis = document.getElementById("p1800"); ellipsis.addEventListener("click", function() { const rows = document.getElementsByClassName("p1799"); for (let i = 0; i < rows.length; i++) { const el = rows[i]; el.style.display = expanded ? "none" : "table-row"; } ellipsis.innerHTML = expanded ? "…)" : "‹‹‹"; expanded = !expanded; }); })(); </script> </div> <br /> <br /> .. code-block:: Python import pandas as pd from io import StringIO import requests pd.options.plotting.backend = "ms_bokeh" # download the file for example plotting url = ( "https://github.com/OpenMS/pyopenms_viz/releases/download/v0.1.5/TestSpectrumDf.tsv" ) response = requests.get(url) response.raise_for_status() # Check for any HTTP errors df = pd.read_csv(StringIO(response.text), sep="\t") # mirror a reference spectrum with ion and sequence annoations df.plot( x="mz", y="intensity", kind="spectrum", ion_annotation="ion_annotation", sequence_annotation="sequence", ) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.232 seconds) .. _sphx_glr_download_gallery_ms_bokeh_plot_spectrum_ms_bokeh.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://notebooks.gesis.org/binder/v2/gh/OpenMS/pyopenms_viz/gh_pages?filepath=notebooks/gallery/ms_bokeh/plot_spectrum_ms_bokeh.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_spectrum_ms_bokeh.ipynb <plot_spectrum_ms_bokeh.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_spectrum_ms_bokeh.py <plot_spectrum_ms_bokeh.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_spectrum_ms_bokeh.zip <plot_spectrum_ms_bokeh.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_