def create_cmap(start,
                end,
                mid=None,
                N=256,
                extend='neither',
                over=None,
                under=None,
                normalize=None):
    """
    Function that creates matplotlib colormaps. Note that input colors must
    be RGB tuples within [0,1].

    Parameters
    ----------
    start : 3-tuple
        RGB-Tuple defining the start color of the color map.

    end : 3-tuple
      RGB-Tuple defining the end color of the color map.

    mid : list (optional, default = None)
      List of tuples (pos, col) specifying any colors in between start and
      end. In this context, 0. < pos < 1. specifiies the position of col
      (passed as RGB tuple) within the color map range.

    N : int (optional, default = 256)
      The number of rgb quantization levels.

    extend : string (optional, one of {*'neither'*, 'both', 'max', 'min'})
      Extend the colorbar and indicate this by triangles at the respective
      ends. See eg. here:

          http://matplotlib.org/examples/pylab_examples/contourf_demo.html

    over : 3-tuple (optional, default = None)
      Color definition for everything out of the upper range of the colormap.
      This is only meaningful if you set the ``extend`` option correctly.
      Uses ``end`` by default.

    under : 3-tuple (optional, default = None)
      Same as ``over`` but for the lower limit. Uses ``start`` by default.

    Returns
    -------
    cmap : LinearSegmentedColormap instance
        color map, ready to be used with matplotlib.

    Examples
    --------
    If you want a colormap ranging from tumblue over white to tumorange, you
    call this function via

    >>> cmap = create_cmap(start = tumcolors['tumblue'],
                           end   = tumcolors['tumorange'],
                           mid   = [(0.5, tumcolors['white'])]
                          )

    You can also go straight from tumblue to tumorange:

    >>> cmap = create_cmap(start = tumcolors['tumblue'],
                           end   = tumcolors['tumorange'])

    Or you can add several colors in between:

    >>> cmap = create_cmap(start = tumcolors['tumblue'],
                           end   = tumcolors['tumorange'],
                           mid   = [(0.3, tumcolors['white']),
                                    (0.7, tumcolors['black'])]
                           )

    """
    from matplotlib.colors import LinearSegmentedColormap

    cdict = dict()
    for i, channel in enumerate(['red', 'green', 'blue']):
        cdict_content = [[0.0, start[i], start[i]]]
        if mid is not None:
            try:
                for pos, col in mid:
                    cdict_content.append([pos, col[i], col[i]])
            except TypeError:
                pos, col = mid
                cdict_content.append([pos, col[i], col[i]])

        cdict_content.append([1.0, end[i], end[i]])
        cdict[channel] = cdict_content
    cmap = LinearSegmentedColormap('custom_cmap', cdict, N)

    # extend
    cmap.colorbar_extend = extend

    if under is None:
        under = start
    if over is None:
        over = end

    cmap.set_over(over)
    cmap.set_under(under)

    return cmap