def draw_rect(ax: plt.Figure, coords: Tuple[List[int], List[int]], c: str = 'white', lw: Union[float, int] = 2, outline: bool = True): ''' Draws a rectangle on ax and returns patch object :param ax: (matplotlib.axes._subplots.AxesSubplot) object :param coords: tuple(list(int)) top-left and bottom-right rect corner coords in pixels :param c: (str) color of rectangle :param lw: (float) or (int) width of line :param outline: (bool) draw or not black outline with lw=4 :return: patch object ''' patch = ax.add_patch( patches.Rectangle(coords[0], *coords[1], fill=False, edgecolor=c, lw=lw)) if outline: draw_outline(patch, 4, c='black') return patch