Ejemplo n.º 1
0
def iter_color_groups(mapping, prefs):
    """Iterates over color groups for each category given mapping file/prefs.

    See get_group_colors for details of algorithm.
    """
    # Iterate through prefs and color by given mapping labels
    for key in natsort(prefs.keys()):
        col_name = prefs[key]["column"]
        if "colors" in prefs[key]:
            if isinstance(prefs[key]["colors"], dict):
                colors = prefs[key]["colors"].copy()  # copy so we can mutate
            else:
                colors = prefs[key]["colors"][:]
        else:
            colors = {}
        labelname = prefs[key]["column"]

        # Define groups and associate appropriate colors to each group
        groups = group_by_field(mapping, col_name)
        colors, data_colors, data_color_order = get_group_colors(groups, colors)

        yield labelname, groups, colors, data_colors, data_color_order
Ejemplo n.º 2
0
def iter_color_groups(mapping, prefs):
    """Iterates over color groups for each category given mapping file/prefs.

    See get_group_colors for details of algorithm.
    """
    #Iterate through prefs and color by given mapping labels
    for key in natsort(prefs.keys()):
        col_name = prefs[key]['column']
        if 'colors' in prefs[key]:
            if isinstance(prefs[key]['colors'], dict):
                colors = prefs[key]['colors'].copy()    #copy so we can mutate
            else:
                colors = prefs[key]['colors'][:]
        else:
            colors={}
        labelname=prefs[key]['column']
        
        #Define groups and associate appropriate colors to each group
        groups = group_by_field(mapping, col_name)
        colors, data_colors, data_color_order = \
            get_group_colors(groups, colors)

        yield labelname, groups, colors, data_colors, data_color_order