コード例 #1
0
def add_vicon_start_stop(axs: np.ndarray, start_i: int, end_i: int) -> None:
    """Add a vertical line to each axes contained in axs (could be multi-dimensional) at start_i, and end_i.

    Expand the the axes limits if start_i or end_i does not lie within the Axes.get_xlim().
    """

    if isinstance(axs, Iterable):
        for ax in axs:
            add_vicon_start_stop(ax, start_i, end_i)
    elif isinstance(axs, axes.Axes):
        if start_i <= axs.get_xlim()[0]:
            axs.set_xlim(left=start_i - 5)
        if end_i >= axs.get_xlim()[1]:
            axs.set_xlim(right=end_i + 5)
        axs.axvline(start_i)
        axs.axvline(end_i)
    else:
        raise TypeError(
            'Only arrays of matplotlib.axes objects can be utilized.')