def plotContig(contig, tracks, options, plot_legend=False,
               extra_features=None):
    """plot data for contig."""

    if extra_features and "figure" in extra_features:
        figure = pylab.figure(**enterParams(extra_features['figure'],
                                            (("figsize", lambda x: map(int, x.split(","))),
                                             ("dpi", int),
                                             "facecolor",
                                             "edgecolor")))
    else:
        figure = pylab.figure()

    if plot_legend:
        if extra_features and "legend" in extra_features:
            legend = pylab.figure(**enterParams(extra_features['legend'],
                                                (("figsize", lambda x: map(int, x.split(","))),
                                                 ("dpi", int),
                                                 "facecolor",
                                                 "edgecolor")))
        else:
            legend = pylab.figure()
        lx = legend.add_axes((0.1, 0.1, 0.9, 0.9))
        lx.set_title("Legend")
        lx.set_axis_off()
    else:
        legend = None

    axes = []

    ywidth = 0.8 / float(len(tracks))
    yoffset = 0.1

    axprops = {}
    ayprops = {}

    min_x, max_x = 1000000000, 0

    for track in tracks:
        if track.mData:
            min_x = min(min_x, min(map(lambda x: (x[0]), track.mData[contig])))
            max_x = max(max_x, max(map(lambda x: (x[1]), track.mData[contig])))

    # make sure that we use the same view for all axes
    axprops['xlim'] = (min_x, max_x)

    nplotted = 0
    for track in tracks:

        labels, plots = [], []

        ax = figure.add_axes(
            (0.1, track.mYOffset, 0.8, track.mYWidth), **axprops)

        if 'sharex' not in axprops:
            ax.xaxis.set_major_formatter(
                matplotlib.ticker.FuncFormatter(formatGenomicCoordinate))
            ax.set_xlabel("Genomic position / Mb")
            axprops['sharex'] = ax
        else:
            pylab.setp(ax.get_xticklabels(), visible=False)

        ax.set_ylabel(track.mTitle, **ayprops)

        if track.mSubTracks:

            # compute maximum extent of y-axis in all of subtracks
            first = True
            for tt in track.mSubTracks:
                if first:
                    min_y = min(map(lambda x: x[2], tt.mData[contig]))
                    max_y = max(map(lambda x: x[2], tt.mData[contig]))
                    first = False
                else:
                    min_y = min(
                        min_y, min(map(lambda x: x[2], tt.mData[contig])))
                    max_y = max(
                        max_y, max(map(lambda x: x[2], tt.mData[contig])))

            nsubplotted = 0
            for tt in track.mSubTracks:
                plot = addPlot(ax, tt, contig, nplotted,
                               nsubplotted, len(track.mSubTracks),
                               min_y, max_y)
                nsubplotted += 1
                plots.append(plot)
                if hasattr(tt, "legend"):
                    labels.append(tt.legend)
                else:
                    labels.append(tt.mTitle)

        else:
            min_y = min(map(lambda x: x[2], track.mData[contig]))
            max_y = max(map(lambda x: x[2], track.mData[contig]))

            if options.global_colours:
                n_for_colour = nplotted
            else:
                n_for_colour = 0

            plot = addPlot(ax, track, contig, n_for_colour)
            plots.append(plot)
            if hasattr(track, "legend"):
                lables.append(track.legend)
            else:
                labels.append(track.mTitle)

        # reduce number of ticks by 2
        old_ticks = ax.get_yticks()
        step_size = (old_ticks[0] - old_ticks[1]) * 2
        new_ticks = list(pylab.arange(old_ticks[0], old_ticks[-1], step_size))
        ax.set_yticks(new_ticks)

        if nplotted % 2 == 0:
            ax.yaxis.set_ticks_position("right")
            ax.yaxis.set_label_position("right")
        else:
            ax.yaxis.set_ticks_position("left")
            ax.yaxis.set_label_position("left")

        # deal with extra_features
        if extra_features:
            for key, config in extra_features.items():
                if key == "vlines":
                    if contig not in config.mData:
                        continue
                    lines = []
                    for start, end, value in config.mData[contig]:
                        lines.append(start)
                        lines.append(end)
                    ax.vlines(
                        lines, min_y, max_y, **enterParams(config, ("colour", "linewidth")))

        nplotted += 1

        if legend:
            lx = legend.add_axes((0.1, track.mYOffset, 0.8, track.mYWidth))
            pylab.setp(lx.get_xticklabels(), visible=False)
            lx.set_xticks([])
            lx.set_yticks([])
            lx.text(0.4, 0.5, track.mTitle)
            lx.legend(plots, labels, 'center left')
            if hasattr(track, "text"):
                lx.text(0.6, 0.2, track.text, size="smaller",
                        clip_on=True)

    ax.set_title(contig)
    # has to be set at the end, otherwise re-scaled?
    ax.set_xlim(min_x, max_x)

    return figure, legend
dataset/ETHPy150Open CGATOxford/cgat/scripts/gff2plot.py/plotContig/swapped operands of `-`