Пример #1
0
    def plot_segmentlist(self, segmentlist, y=None, collection=True,
                         label=None, rasterized=None, **kwargs):
        """Plot a :class:`~gwpy.segments.SegmentList` onto these axes

        Parameters
        ----------
        segmentlist : :class:`~gwpy.segments.SegmentList`
            list of segments to display
        y : `float`, optional
            y-axis value for new segments
        collection : `bool`, default: `True`
            add all patches as a
            :class:`~matplotlib.collections.PatchCollection`, doesn't seem
            to work for hatched rectangles
        label : `str`, optional
            custom descriptive name to print as y-axis tick label
        **kwargs
            any other keyword arguments acceptable for
            :class:`~matplotlib.patches.Rectangle`

        Returns
        -------
        collection : :class:`~matplotlib.patches.PatchCollection`
            list of :class:`~matplotlib.patches.Rectangle` patches
        """
        if y is None:
            y = self.get_next_y()
        patches = []
        for seg in segmentlist:
            patches.append(self.build_segment(seg, y, **kwargs))
        try:
            if not self.epoch:
                self.set_epoch(segmentlist[0][0])
            else:
                self.set_epoch(min(self.epoch, segmentlist[0][0]))
        except IndexError:
            pass
        if collection:
            coll = PatchCollection(patches, len(patches) != 0)
            coll.set_rasterized(rasterized)
            if label is not None:
                coll.set_label(rUNDERSCORE.sub(r'\_', str(label)))
            if collection == 'ignore':
                coll._ignore = True
            else:
                coll._ignore = False
            coll._ypos = y
            out = self.add_collection(coll)
        else:
            out = []
            for p in patches:
                p.set_label(label)
                p.set_rasterized(rasterized)
                label = ''
                out.append(self.add_patch(p))
        self.autoscale(axis='y')
        return out
Пример #2
0
    def plot_segmentlist(self,
                         segmentlist,
                         y=None,
                         collection=True,
                         label=None,
                         rasterized=None,
                         **kwargs):
        """Plot a :class:`~gwpy.segments.SegmentList` onto these axes

        Parameters
        ----------
        segmentlist : :class:`~gwpy.segments.SegmentList`
            list of segments to display
        y : `float`, optional
            y-axis value for new segments
        collection : `bool`, default: `True`
            add all patches as a
            :class:`~matplotlib.collections.PatchCollection`, doesn't seem
            to work for hatched rectangles
        label : `str`, optional
            custom descriptive name to print as y-axis tick label
        **kwargs
            any other keyword arguments acceptable for
            :class:`~matplotlib.patches.Rectangle`

        Returns
        -------
        collection : :class:`~matplotlib.patches.PatchCollection`
            list of :class:`~matplotlib.patches.Rectangle` patches
        """
        if y is None:
            y = self.get_next_y()
        patches = []
        for seg in segmentlist:
            patches.append(self.build_segment(seg, y, **kwargs))
        try:
            if not self.epoch:
                self.set_epoch(segmentlist[0][0])
            else:
                self.set_epoch(min(self.epoch, segmentlist[0][0]))
        except IndexError:
            pass
        if collection:
            coll = PatchCollection(patches, len(patches) != 0)
            coll.set_rasterized(rasterized)
            if label is not None:
                coll.set_label(rUNDERSCORE.sub(r'\_', str(label)))
            if collection == 'ignore':
                coll._ignore = True
            else:
                coll._ignore = False
            coll._ypos = y
            out = self.add_collection(coll)
        else:
            out = []
            for p in patches:
                p.set_label(label)
                p.set_rasterized(rasterized)
                label = ''
                out.append(self.add_patch(p))
        self.autoscale(axis='y')
        return out
Пример #3
0
    def plot_segmentlist(self,
                         segmentlist,
                         y=None,
                         height=.8,
                         label=None,
                         collection=True,
                         rasterized=None,
                         **kwargs):
        """Plot a `~gwpy.segments.SegmentList` onto these axes

        Parameters
        ----------
        segmentlist : `~gwpy.segments.SegmentList`
            list of segments to display

        y : `float`, optional
            y-axis value for new segments

        collection : `bool`, default: `True`
            add all patches as a
            `~matplotlib.collections.PatchCollection`, doesn't seem
            to work for hatched rectangles

        label : `str`, optional
            custom descriptive name to print as y-axis tick label

        **kwargs
            any other keyword arguments acceptable for
            `~matplotlib.patches.Rectangle`

        Returns
        -------
        collection : `~matplotlib.patches.PatchCollection`
            list of `~matplotlib.patches.Rectangle` patches
        """
        # get colour
        facecolor = kwargs.pop('facecolor', kwargs.pop('color', '#629fca'))
        if is_color_like(facecolor):
            kwargs.setdefault('edgecolor', tint(facecolor, factor=.5))

        # get y
        if y is None:
            y = self.get_next_y()

        # build patches
        patches = [
            SegmentRectangle(seg,
                             y,
                             height=height,
                             facecolor=facecolor,
                             **kwargs) for seg in segmentlist
        ]

        if collection:  # map to PatchCollection
            coll = PatchCollection(patches,
                                   match_original=patches,
                                   zorder=kwargs.get('zorder', 1))
            coll.set_rasterized(rasterized)
            coll._ignore = collection == 'ignore'
            coll._ypos = y
            out = self.add_collection(coll)
            # reset label with tex-formatting now
            #   matplotlib default label is applied by add_collection
            #   so we can only replace the leading underscore after
            #   this point
            if label is None:
                label = coll.get_label()
            coll.set_label(to_string(label))
        else:
            out = []
            for patch in patches:
                patch.set_label(label)
                patch.set_rasterized(rasterized)
                label = ''
                out.append(self.add_patch(patch))
        self.autoscale(enable=None, axis='both', tight=False)
        return out
Пример #4
0
    def plot_segmentlist(self,
                         segmentlist,
                         y=None,
                         collection=True,
                         label=None,
                         rasterized=None,
                         **kwargs):
        """Plot a `~gwpy.segments.SegmentList` onto these axes

        Parameters
        ----------
        segmentlist : `~gwpy.segments.SegmentList`
            list of segments to display

        y : `float`, optional
            y-axis value for new segments

        collection : `bool`, default: `True`
            add all patches as a
            `~matplotlib.collections.PatchCollection`, doesn't seem
            to work for hatched rectangles

        label : `str`, optional
            custom descriptive name to print as y-axis tick label

        **kwargs
            any other keyword arguments acceptable for
            `~matplotlib.patches.Rectangle`

        Returns
        -------
        collection : `~matplotlib.patches.PatchCollection`
            list of `~matplotlib.patches.Rectangle` patches
        """
        if y is None:
            y = self.get_next_y()
        patches = []
        for seg in segmentlist:
            patches.append(self.build_segment(seg, y, **kwargs))
        try:
            if not self.epoch:
                self.set_epoch(segmentlist[0][0])
            else:
                self.set_epoch(min(self.epoch, segmentlist[0][0]))
        except IndexError:
            pass
        if collection:
            coll = PatchCollection(patches, match_original=patches)
            coll.set_rasterized(rasterized)
            coll._ignore = collection == 'ignore'
            coll._ypos = y
            out = self.add_collection(coll)
            # reset label with tex-formatting now
            #   matplotlib default label is applied by add_collection
            #   so we can only replace the leading underscore after
            #   this point
            if label is None:
                label = coll.get_label()
            coll.set_label(to_string(label))
        else:
            out = []
            for patch in patches:
                patch.set_label(label)
                patch.set_rasterized(rasterized)
                label = ''
                out.append(self.add_patch(patch))
        self.autoscale(axis='y')
        return out
Пример #5
0
    def plot_segmentlist(self, segmentlist, y=None, height=.8, label=None,
                         collection=True, rasterized=None, **kwargs):
        """Plot a `~gwpy.segments.SegmentList` onto these axes

        Parameters
        ----------
        segmentlist : `~gwpy.segments.SegmentList`
            list of segments to display

        y : `float`, optional
            y-axis value for new segments

        collection : `bool`, default: `True`
            add all patches as a
            `~matplotlib.collections.PatchCollection`, doesn't seem
            to work for hatched rectangles

        label : `str`, optional
            custom descriptive name to print as y-axis tick label

        **kwargs
            any other keyword arguments acceptable for
            `~matplotlib.patches.Rectangle`

        Returns
        -------
        collection : `~matplotlib.patches.PatchCollection`
            list of `~matplotlib.patches.Rectangle` patches
        """
        # get colour
        facecolor = kwargs.pop('facecolor', kwargs.pop('color', '#629fca'))
        if is_color_like(facecolor):
            kwargs.setdefault('edgecolor', tint(facecolor, factor=.5))

        # get y
        if y is None:
            y = self.get_next_y()

        # build patches
        patches = [SegmentRectangle(seg, y, height=height, facecolor=facecolor,
                                    **kwargs) for seg in segmentlist]

        if collection:  # map to PatchCollection
            coll = PatchCollection(patches, match_original=patches,
                                   zorder=kwargs.get('zorder', 1))
            coll.set_rasterized(rasterized)
            coll._ignore = collection == 'ignore'
            coll._ypos = y
            out = self.add_collection(coll)
            # reset label with tex-formatting now
            #   matplotlib default label is applied by add_collection
            #   so we can only replace the leading underscore after
            #   this point
            if label is None:
                label = coll.get_label()
            coll.set_label(to_string(label))
        else:
            out = []
            for patch in patches:
                patch.set_label(label)
                patch.set_rasterized(rasterized)
                label = ''
                out.append(self.add_patch(patch))
        self.autoscale(enable=None, axis='both', tight=False)
        return out
Пример #6
0
    def plot_segmentlist(self, segmentlist, y=None, collection=True,
                         label=None, rasterized=None, **kwargs):
        """Plot a `~gwpy.segments.SegmentList` onto these axes

        Parameters
        ----------
        segmentlist : `~gwpy.segments.SegmentList`
            list of segments to display

        y : `float`, optional
            y-axis value for new segments

        collection : `bool`, default: `True`
            add all patches as a
            `~matplotlib.collections.PatchCollection`, doesn't seem
            to work for hatched rectangles

        label : `str`, optional
            custom descriptive name to print as y-axis tick label

        **kwargs
            any other keyword arguments acceptable for
            `~matplotlib.patches.Rectangle`

        Returns
        -------
        collection : `~matplotlib.patches.PatchCollection`
            list of `~matplotlib.patches.Rectangle` patches
        """
        if y is None:
            y = self.get_next_y()
        patches = []
        for seg in segmentlist:
            patches.append(self.build_segment(seg, y, **kwargs))
        try:
            if not self.epoch:
                self.set_epoch(segmentlist[0][0])
            else:
                self.set_epoch(min(self.epoch, segmentlist[0][0]))
        except IndexError:
            pass
        if collection:
            coll = PatchCollection(patches, match_original=patches)
            coll.set_rasterized(rasterized)
            coll._ignore = collection == 'ignore'
            coll._ypos = y
            out = self.add_collection(coll)
            # reset label with tex-formatting now
            #   matplotlib default label is applied by add_collection
            #   so we can only replace the leading underscore after
            #   this point
            if label is None:
                label = coll.get_label()
            coll.set_label(to_string(label))
        else:
            out = []
            for patch in patches:
                patch.set_label(label)
                patch.set_rasterized(rasterized)
                label = ''
                out.append(self.add_patch(patch))
        self.autoscale(axis='y')
        return out