def plot_nphist2d_contour(ax, hist, bins, level, color=None, label=None, **
    kwargs):
    """Draw level contour for the 2D numpy histogram.

    Parameters
    ----------
    ax : Axes
        Matplotlib axes on which contours will be plotted.
    hist : ndarray, shape (N,M)
        Histogram to be plotted.
    bins : (ndarray, ndarray)
        Bind edges for the histograms.
    level : float or list of float
        Value of level(s) at which contour(s) will be drawn.
    color : str or list of str or None, optional
        Colors for each contour to be drawn. If `color` is a str then
        all contours will have the same color.
    label : str or list of str or None, optional
        Labels for contours. If `label` is str, then only the first contour
        will be labeled.
    kwargs : dict, optional
        Additional parameters to pass directly to the pyplot.contour function

    Returns
    -------
    pyplot.contour.QuadContourSet
        Matplotlib contour set
    """
    bins_x = bins[0]
    bins_y = bins[1]
    range_x = bins_x[0], bins_x[-1]
    range_y = bins_y[0], bins_y[-1]
    centers_x = (bins_x[1:] + bins_x[:-1]) / 2
    centers_y = (bins_y[1:] + bins_y[:-1]) / 2
    if isinstance(level, (tuple, list)):
        levels = level
    else:
        levels = [level]
    contour_set = ax.contour(centers_x, centers_y, hist.T, levels=levels,
        origin='lower', extent=range_x + range_y, colors=color, **kwargs)
    if label is not None:
        if isinstance(label, (tuple, list)):
            for l, c in zip(label, contour_set.collections):
                c.set_label(l)
        else:
            contour_set.collections[0].set_label(label)
    return contour_set
