Data table histogramsΒΆ

The EventTable object comes with a hist() method, allowing trivial generation of histograms using any column as the counter:

EventTable.hist(self, column, **kwargs)[source]

Generate a HistogramPlot of this Table.

Parameters

column : str

Name of the column over which to histogram data

method : str, optional

Name of Axes method to use to plot the histogram, default: 'hist'.

**kwargs

Any other keyword arguments, see below.

Returns

plot : Plot

The newly created figure.

See also

matplotlib.pyplot.figure

for documentation of keyword arguments used to create the figure.

matplotlib.figure.Figure.add_subplot

for documentation of keyword arguments used to create the axes.

gwpy.plot.Axes.hist

for documentation of keyword arguments used to display the histogram, if the method keyword is given, this method might not actually be the one used.

Using the above method we can generate a histogram as follows

>>> from gwpy.table import EventTable
>>> events = EventTable.read('H1-LDAS_STRAIN-968654552-10.xml.gz', tablename='sngl_burst', columns=['snr'])
>>> plot = events.hist('snr', weights=1/10., logbins=True, bins=50, histtype='stepfilled')
>>> ax = plot.gca()
>>> ax.set_xlabel('Signal-to-noise ratio (SNR)')
>>> ax.set_ylabel('Rate [Hz]')
>>> ax.set_title('LHO event triggers for HW100916')
>>> ax.autoscale(axis='x', tight=True)
>>> plot.show()

(png)

../_images/histogram-1.png

This is a snippet from the example Plotting an EventTable in a histogram.