def addPlot(ax, track, contig, nplotted,
            nsubplotted=None,
            nsubplots=None,
            y_min=None,
            y_max=None):
    """add a track to an axes object.
    """

    if contig not in track.mData:
        return

    # step function
    # datapoint is in window average
    xvals = map(lambda x: (x[1] + x[0]) / 2.0, track.mData[contig])
    yvals = map(lambda x: x[2], track.mData[contig])
    l = len(xvals)

    if nsubplots:
        plotnum = nsubplotted
    else:
        plotnum = nplotted

    if track.style == "matrix":

        # unequal window sizes confuse the image. Therefore, normalize
        # xvals and yvals to a constant image size
        matrix = pylab.array(yvals)
        matrix.shape = (1, len(yvals))

        # make sure that the extent of the image and the plot coincide by
        # using extent
        if nsubplots is not None:
            y_width = float(y_max - y_min) / nsubplots
            extent = (min(xvals), max(xvals), y_min + y_width *
                      nsubplotted, y_min + y_width * (nsubplotted + 1))
        else:
            extent = (min(xvals), max(xvals), min(yvals), max(yvals))
        ax.imshow(matrix,
                  cmap=track.color_scheme,
                  extent=extent,
                  interpolation="nearest")

        symbol = options.symbols[plotnum % len(options.symbols)]
        plot = ax.plot(xvals, yvals, symbol, lw=2)
    else:
        symbol = options.symbols[plotnum % len(options.symbols)]
        plot = ax.plot(xvals, yvals, symbol)

    return plot

#-------------------------------------------------------------------
#-------------------------------------------------------------------
#-------------------------------------------------------------------
dataset/ETHPy150Open CGATOxford/cgat/scripts/gff2plot.py/addPlot/original