def calculate_cbar_dims(img_width, img_figsize, img_height):
    """
    Helper for plot_topomap_3d_brain when plotting multiple views and using the
    matplotlib backend. Calculates the colorbar width and height to be placed
    correctly.

    Parameters:
        img_width: matplotlib.figure.Figure
            Number of brain images to include horizontally.
        img_figsize: int
            Total height/width of the image in inches (square image).
        img_height: int
            Number of brain images to include vertically.

    Returns:
        cbar_width: float
            Width of colorbar in matplotlib units.
        cbar_height: float
            Height of colorbar in matplotlib units.
    """
    cbar_adjustments_table = {1: [1.365, 1.43],
                              2: [0.689, 0.71],
                              3: [0.611, 0.57],
                              4: [0.559, 0.50],
                              5: [0.494, 0.45],
                              6: [0.455, 0.40],
                              7: [0.429, 0.38]}
    cbar_adjustments = cbar_adjustments_table[img_width]
    
    cbar_height = img_figsize * img_width * cbar_adjustments[0]
    cbar_width = img_figsize * img_width * cbar_adjustments[1]
    
    return cbar_width, cbar_height