Exemplo n.º 1
0
    def _setup_gen_legend(self, pattern, legendnames=None):
        if not legendnames:
            legendnames = util.setup_legendnames_from_files(pattern)

        # update colors (sorting needed, since dict is unsorted, and parallel
        # plotters should have the same result.
        for l in sorted(legendnames.itervalues()):
            analysis.get_color(l)

        legendnames = dict(
            (os.path.basename(p), l) for p, l in legendnames.iteritems())
        self.message(
            'INFO Legend names that I will use if not overwritten:\n' +
            '\n'.join('%32s: %s' % (v, k) for k, v in legendnames.iteritems()))

        def gen_apply_legend(wrps):
            for w in wrps:
                if not w.legend:
                    w.legend = legendnames[os.path.basename(w.file_path)]
                yield w

        return gen_apply_legend
Exemplo n.º 2
0
def apply_markercolor(wrps, colors=None):
    """
    Uses ``histo.SetMarkerColor``. Colors from analysis module, if not given.

    :param wrps:    HistoWrapper iterable
    :param colors:  Integer list
    :yields:        HistoWrapper
    """
    n = 0
    for wrp in wrps:
        if colors:
            color = colors[n % len(colors)]
            n += 1
        else:
            color = analysis.get_color(wrp.legend, wrp.sample)
        if color:
            wrp.obj.SetMarkerColor(color)
        yield wrp
Exemplo n.º 3
0
def touch_legend_color(wrps):
    """Make sure a color exists for every legend."""
    for wrp in wrps:
        analysis.get_color(wrp.legend)
        yield wrp