def fill_bin_content(ax, sensitivity, energy_bin, n_bins_gammaness, n_bins_theta2):
    """
    Function to fill bin content to be plotted in the case of an
    optimized figure array

    Parameters
    ----------
    ax:    `matplotlib.pyplot.axis`
    sensitivity:  `numpy.ndarray`  sensitivity array
    energy_bin:    `int`  energy bin number
    n_bins_gammaness:    `int`  number of bins in gammaness
    n_bins_theta2:    `int`  number of bins in theta2

    Returns
    -------
    ax:    `matplotlib.pyplot.axis`

    """

    for i in range(0, n_bins_gammaness):
        for j in range(0, n_bins_theta2):
            # With theta2, we start the binning in 0.005 deg^2 and increase up to n_bins_theta2 steps
            # up to reach 0.05 deg^2
            theta2 = 0.005 + 0.005 / 2 + ((0.05 - 0.005) / n_bins_theta2) * j
            # With gammaness, we start with 0.05 and increase up to n_bins_gammaness steps
            # up to reaching 1
            gammaness = 0.1 / 2 + (1 / n_bins_gammaness) * i
            ax.text(theta2, gammaness, "%.2f %%" % sensitivity[energy_bin][i][j],
                    ha="center", va="center", color="w", size=8)
    return ax