Get the opacity transfer function results: range from 0 to 255

def opacity_transfer_function(key, n_colors):
    """Get the opacity transfer function results: range from 0 to 255
    """
    transfer_func = {
        'linear': np.linspace(0, 255, n_colors, dtype=np.uint8),
        'linear_r': np.linspace(0, 255, n_colors, dtype=np.uint8)[::-1],
        'geom': np.geomspace(1e-6, 255, n_colors, dtype=np.uint8),
        'geom_r': np.geomspace(255, 1e-6, n_colors, dtype=np.uint8),
    }
    try:
        return transfer_func[key]
    except KeyError:
        raise KeyError('opactiy transfer function ({}) unknown.'.format(key))