def before_after_histogram( outfile, x, y, label1='Before', label2='After', bins=100, histtype='stepfilled', range=None, figsize=[9, 6], **kwargs): """Plot a histogram of SNR for two event distributions """ # format axis arguments axargs = { 'xscale': 'log', 'xlabel': 'Loudness', 'yscale': 'log', 'ylabel': 'Number of events', } axargs.update(kwargs) # create figure plot = HistogramPlot(figsize=figsize) ax = plot.gca() # make histogram if range is None: range = ax.common_limits((x, y)) axargs.setdefault('xlim', range) histargs = { 'range': range, 'histtype': histtype, 'bins': bins, 'linewidth': 2, 'logbins': axargs['xscale'] == 'log', 'alpha': .8, } ax.hist(x, label=label1, facecolor='red', edgecolor='darkred', **histargs) ax.hist(y, label=label2, facecolor='dodgerblue', edgecolor='blue', **histargs) # add legend ax.legend(loc='upper right') # format axes axargs.setdefault('ylim', (.5, ax.yaxis.get_data_interval()[1] * 1.05)) _finalize_plot(plot, ax, outfile, **axargs)
def hist(self, column, **kwargs): """Generate a `HistogramPlot` of this `Table`. Parameters ---------- column : `str` name of the column over which to histogram data **kwargs any other arguments applicable to the `HistogramPlot` Returns ------- plot : `~gwpy.plotter.HistogramPlot` new plot displaying a histogram of this `Table`. """ from gwpy.plotter import HistogramPlot return HistogramPlot(self, column, **kwargs)
def plot_vco_hist(amps, spans, channel): for amp, span in zip(amps.keys(), spans.keys()): start = spans[span][0] end = spans[span][-1] png = plot_name(channel, start, end, 'VCO-HIST', format='png') plot = HistogramPlot(amps[amp], weights=1 / abs(spans[span]), bins=100, log=True) plot.set_xlabel('Amplitude [kHz from 79 MHz]') plot.set_ylabel('Rate [Hz]') plot.set_title(channel.replace('_', '\_') + ' omicron glitch histogram') plot.suptitle(str(spans[span][0]) + '-' + str(spans[span][-1])) ax = plot.gca() plot.save(png) plot.close() print('%s written' % png)
def plot_vco_hist(vco_trigs, segment, channel): start = segment[0] end = segment[1] png = plot_name(channel, start, end, "VCO-HIST", format="png") plot = HistogramPlot(vco_trigs, weights=1.0 / abs(int(end) - int(start)), bins=100, log=True) plot.set_xlabel("VCO Frequency [kHz from 79 MHz]") plot.set_ylabel("Rate [Hz]") plot.set_title(channel.replace("_", "\_") + " omicron glitch histogram", fontsize=14) plot.suptitle(str(segment[0]) + "-" + str(segment[-1])) ax = plot.gca() plot.savefig(png) plot.close() print("%s written" % png)
def plot_vco_hist(vco_trigs, segment, channel): start = segment[0] end = segment[1] png = plot_name(channel, start, end, 'VCO-HIST', format='png') plot = HistogramPlot( vco_trigs, weights=1. / abs(int(end) - int(start)), bins=100, log=True) plot.set_xlabel('VCO Frequency [kHz from 79 MHz]') plot.set_ylabel('Rate [Hz]') plot.set_title(channel.replace('_', '\_') + ' omicron glitch histogram', fontsize=14) plot.suptitle(str(segment[0]) + '-' + str(segment[-1])) ax = plot.gca() plot.savefig(png) plot.close() print('%s written' % png)