def get_twin(ax):
    """
    Retrieves a twin Y axis for a given matplotlib axis. This is useful when we have two axes one placed at each side
    of the plot.
    @param ax: the known matplotlib axis.
    @return: the twin axis.
    """
    for other_ax in ax.figure.axes:
        if other_ax is ax:
            continue
        if other_ax.bbox.bounds == ax.bbox.bounds:
            return other_ax
    return None