2. Plotting an EventTable in a histogramΒΆ

I would like to study the distribution of the GW events detected to date.

First, we can download the 'GWTC-1-confident' catalogue using EventTable.fetch_open_data():

from gwpy.table import EventTable
events = EventTable.fetch_open_data(
    "GWTC-1-confident",
    columns=("mass1", "mass2"),
)
events.add_column(events["mass1"] + events["mass2"], name="mtotal")

and can generate a new Plot using the hist() method:

plot = events.hist('mtotal', bins=10, 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-1-confident")
plot.show()

(png)

../../_images/histogram-2.png