def get_axis(axes, row_nb, col_nb, row_idx, col_idx):
    """
    Extract matplotlib axis among array of axis returned
    by subplots, handling the fact that the number of dimensions
    is affected by the number of columns and rows.
    """
    if row_nb == 1 and col_nb == 1:
        ax = axes
    elif col_nb > 1 and row_nb == 1:
        ax = axes[col_idx]
    elif col_nb == 1 and row_nb > 1:
        ax = axes[row_idx]
    else:
        ax = axes[row_idx, col_idx]
    ax.axis("off")
    return ax