Convert the given data (2d array of numbers or binary strings) to a 2d
    array of RGB or RGBA values which can then be visualized as a heat map.

    Arguments:
    data - 2d array of numbers or binary strings
    palette - a seaborn palette (list of RGB values) indicating how to convert
              data to colors. Will be converted to a continuous colormap if
              necessary. This should generally be the length of the longest
              binary string or the highest possible number
    denom - if the data is composed of numbers rather than binary strings,
            this number will indicate how to normalize the data to [0, 1]
            should it be neccessary.
    mask_zeros - Boolean indicating whether 0s should be colored white rather
                 than the color specified by the palette. -1s always yield
                 -1 so that missing data can be handled appropriately.

def color_grid(data, palette, denom=9.0, mask_zeros=True):
    """
    Convert the given data (2d array of numbers or binary strings) to a 2d
    array of RGB or RGBA values which can then be visualized as a heat map.

    Arguments:
    data - 2d array of numbers or binary strings
    palette - a seaborn palette (list of RGB values) indicating how to convert
              data to colors. Will be converted to a continuous colormap if
              necessary. This should generally be the length of the longest
              binary string or the highest possible number
    denom - if the data is composed of numbers rather than binary strings,
            this number will indicate how to normalize the data to [0, 1]
            should it be neccessary.
    mask_zeros - Boolean indicating whether 0s should be colored white rather
                 than the color specified by the palette. -1s always yield
                 -1 so that missing data can be handled appropriately.

    """
    grid = []

    try:
        # If this isn't numeric, don't bother with this block
        float(data[0][0])

        # This is continuous data - we need a colormap rather than palette
        palette = matplotlib.colors.LinearSegmentedColormap.from_list(
                "color_grid", palette)
        palette.set_bad(alpha=0)
    except:
        pass

    for row in range(len(data)):
        grid.append([])
        for col in range(len(data[row])):

            try:
                rgb = color_array_by_value(data[row][col], palette, denom,
                                           mask_zeros)
            except:
                rgb = color_array_by_hue_mix(data[row][col], palette)

            grid[row].append(rgb)

    return grid