def plot(self, x, y, *args, **kwargs): """Generate an `EventTablePlot` of this `Table`. Parameters ---------- x : `str` name of column defining centre point on the X-axis y : `str` name of column defining centre point on the Y-axis width : `str`, optional name of column defining width of tile height : `str`, optional name of column defining height of tile .. note:: The ``width`` and ``height`` positional arguments should either both be omitted, in which case a scatter plot will be drawn, or both given, in which case a collection of rectangles will be drawn. color : `str`, optional, default:`None` name of column by which to color markers **kwargs any other arguments applicable to the `Plot` constructor, and the `Table` plotter. Returns ------- plot : `~gwpy.plotter.EventTablePlot` new plot for displaying tabular data. 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.plotter.EventTableAxes.plot_table for documentation of keyword arguments used to display the table (calls out to :meth:`~matplotlib.axes.Axes.scatter`) """ from gwpy.plotter import EventTablePlot return EventTablePlot(self, x, y, *args, **kwargs)
def plot(self, x, y, *args, **kwargs): """Generate an `EventTablePlot` of this `Table`. Parameters ---------- x : `str` name of column defining centre point on the X-axis y : `str` name of column defining centre point on the Y-axis width : `str`, optional name of column defining width of tile height : `str`, optional name of column defining height of tile .. note:: The ``width`` and ``height`` positional arguments should either both be omitted, in which case a scatter plot will be drawn, or both given, in which case a collection of rectangles will be drawn. color : `str`, optional, default:`None` name of column by which to color markers **kwargs any other arguments applicable to the `Plot` constructor, and the `Table` plotter. Returns ------- plot : `~gwpy.plotter.EventTablePlot` new plot for displaying tabular data. See Also -------- gwpy.plotter.EventTablePlot for more details. """ from gwpy.plotter import EventTablePlot return EventTablePlot(self, x, y, *args, **kwargs)
def veto_scatter( outfile, a, b, label1='All', label2='Vetoed', x='time', y='snr', color=None, clim=None, clabel=None, cmap=None, clog=True, figsize=[9, 6],**kwargs): """Plot an x-y scatter of all/vetoed events """ # format axis arguments axargs = { 'yscale': 'log', 'ylabel': 'Loudness', } if x != 'time': axargs['xscale'] = 'log' axargs.update(kwargs) # create figure plot = EventTablePlot(base=x=='time' and TimeSeriesPlot or Plot, figsize=figsize) ax = plot.gca() # add data scatterargs = {'s': 40} if color is None: ax.scatter(a[x], a[y], color='black', marker='o', label=label1, s=40) else: colorargs = {'edgecolor': 'none'} if clim: colorargs['vmin'] = clim[0] colorargs['vmax'] = clim[1] if clog: colorargs['norm'] = LogNorm(vmin=clim[0], vmax=clim[1]) a = a.copy() a.sort(order=color) m = ax.scatter(a[x], a[y], c=a[color], label=label1, **colorargs) # add colorbar plot.add_colorbar(mappable=m, ax=ax, cmap=cmap, label=clabel) if isinstance(b, list): colors = list(rcParams['axes.prop_cycle']) else: b = [b] label2 = [label2] colors = [{'color': 'red'}] for i, data in enumerate(b): # setting the color here looks complicated, but is just a fancy # way of looping through the color cycle when scattering, but using # red if we only have one other data set ax.scatter(data[x], data[y], marker='+', linewidth=1.5, label=label2[i], s=40, **colors[i % len(colors)]) # add legend if ax.get_legend_handles_labels()[0]: legargs = { 'loc': 'upper left', 'bbox_to_anchor': (1.01, 1), 'borderaxespad': 0, 'numpoints': 1, 'scatterpoints': 1, 'handlelength': 1, 'handletextpad': .5 } legargs.update(dict((x[7:], axargs.pop(x)) for x in axargs.keys() if x.startswith('legend_'))) ax.legend(**legargs) # finalize for axis in ['x', 'y']: lim = list(getattr(ax, '%saxis' % axis).get_data_interval()) lim[0] = axargs.get('%sbound' % axis, lim[0]) axargs.setdefault('%slim' % axis, (lim[0] * 0.95, lim[1] * 1.05)) _finalize_plot(plot, ax, outfile, **axargs)
def aux_snr_time(omic_trigs,vetoed_omic_trigs, channel): labels = [r"All %d" %len(omic_trigs), r"Used %d" %len(vetoed_omic_trigs)] plot = EventTablePlot(omic_trigs, 'time', 'snr',\ edgecolor='none', label=labels[0]) plot.add_table(vetoed_omic_trigs, 'time', 'snr',\ edgecolor='none', label=labels[1],c='r') plot.set_ylabel('SNR') plot.set_yscale('log',nonposy='clip') plot.set_title(r'Detector=%s, Veto Channel=%s' %(ifo, channel)) ax = plot.gca() lgd = ax.legend(loc="upper left", bbox_to_anchor=(1,1)) save = channel.replace('{\_}', '_') plot.savefig(r'%s_aux_time_snr.png' %save,\ bbox_extra_artists=(lgd,), bbox_inches='tight')