def compute_cell_extents_grid(bounding_rect=(0.03, 0.03, 0.97, 0.97),
                               num_rows=2, num_cols=6,
                               axis_pad=0.01):
    """
    Produces array of num_rows*num_cols elements each containing
    the rectangular extents of the corresponding cell the grid, whose position is
    within bounding_rect.
    """

    left, bottom, width, height = bounding_rect
    height_padding = axis_pad * (num_rows + 1)
    width_padding = axis_pad * (num_cols + 1)
    cell_height = float((height - height_padding) / num_rows)
    cell_width = float((width - width_padding) / num_cols)

    cell_height_padded = cell_height + axis_pad
    cell_width_padded = cell_width + axis_pad

    extents = list()
    for row in range(num_rows - 1, -1, -1):
        for col in range(num_cols):
            extents.append((left + col * cell_width_padded,
                            bottom + row * cell_height_padded,
                            cell_width, cell_height))

    return extents