.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/table/histogram.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. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_table_histogram.py: .. sectionauthor:: Duncan Macleod .. currentmodule:: gwpy.table Plotting an `EventTable` in a histogram ####################################### I would like to study the distribution of the GW events detected to date. .. GENERATED FROM PYTHON SOURCE LINES 30-32 First, we can download the ``'GWTC-1-confident'`` catalogue using :meth:`EventTable.fetch_open_data`: .. GENERATED FROM PYTHON SOURCE LINES 32-43 .. code-block:: Python from gwpy.table import EventTable events = EventTable.fetch_open_data( "GWTC", columns=("mass_1_source", "mass_2_source"), ) events.add_column( events["mass_1_source"] + events["mass_2_source"], name="mtotal" ) .. GENERATED FROM PYTHON SOURCE LINES 44-46 and can generate a new `~gwpy.plot.Plot` using the :meth:`~EventTable.hist` method: .. GENERATED FROM PYTHON SOURCE LINES 46-53 .. code-block:: Python plot = events.hist("mtotal", bins=20, range=(0, 100), histtype="stepfilled") ax = plot.gca() ax.set_xlabel(r"Total mass [M$_{\odot}$]") ax.set_ylabel("Number of events") ax.set_title("GWTC events") plot.show() .. image-sg:: /examples/table/images/sphx_glr_histogram_001.png :alt: GWTC events :srcset: /examples/table/images/sphx_glr_histogram_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.083 seconds) .. _sphx_glr_download_examples_table_histogram.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: histogram.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: histogram.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: histogram.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_