Пример #1
0
def plot_all_directions(r, queries, results, what_to_plot_fun,
                        what_to_plot_res):
    """
        result_like 
        
        result_like = dict(maintenance="s", cost="$", mass='kg')
    """
    n = len(queries)
    assert n == len(results)
    colors = generate_colors(n, colormap_name='Paired')

    marker_fun = marker_res = marker_joint = 'o'

    for xwhat, ywhat in itertools.combinations(what_to_plot_res, 2):
        name = '%s_%s' % (xwhat, ywhat)
        with r.plot(name) as pylab:
            with figure_style1(pylab):
                plot_axis(pylab,
                          results,
                          what_to_plot_res,
                          colors,
                          xwhat,
                          ywhat,
                          marker=marker_res)
            set_axis_colors(pylab, color_resources, color_resources)

    qqueries = [[x] for x in queries]
    for xwhat, ywhat in itertools.combinations(what_to_plot_fun, 2):
        name = '%s_%s' % (xwhat, ywhat)
        with r.plot(name) as pylab:
            with figure_style1(pylab):
                plot_axis(pylab,
                          qqueries,
                          what_to_plot_fun,
                          colors,
                          xwhat,
                          ywhat,
                          marker=marker_fun)
            set_axis_colors(pylab, color_functions, color_functions)

    for xwhat in what_to_plot_fun:
        for ywhat in what_to_plot_res:
            name = '%s_%s' % (xwhat, ywhat)
            with r.plot(name) as pylab:
                with figure_style1(pylab):
                    for fun, res, color in zip(qqueries, results, colors):
                        x = to_numpy_array(what_to_plot_fun, fun)[xwhat]
                        y = to_numpy_array(what_to_plot_res, res)[ywhat]
                        if len(y) == 0:  # unfeasible
                            pylab.plot(x, 0, 'x', color='black')
                        elif len(x) == 1 and len(y) > 1:
                            xs = [x[0]] * len(y)
                            pylab.plot(xs, y, marker_joint, color=color)
                        else:
                            # print x, y
                            pylab.plot(x, y, marker_joint, color=color)
                set_axis_colors(pylab, color_functions, color_resources)

                pylab.xlabel(axis_label(what_to_plot_fun, xwhat))
                pylab.ylabel(axis_label(what_to_plot_res, ywhat))
Пример #2
0
def plot_all_directions(r, queries, results, what_to_plot_fun, what_to_plot_res):
    """
        result_like 
        
        result_like = dict(maintenance="s", cost="$", mass='kg')
    """
    n = len(queries)
    assert n == len(results)
    colors = generate_colors(n, colormap_name='Paired')

    marker_fun = marker_res = marker_joint = 'o'

    for xwhat, ywhat in itertools.combinations(what_to_plot_res, 2):
        name = '%s_%s' % (xwhat, ywhat)
        with r.plot(name) as pylab:
            with figure_style1(pylab):
                plot_axis(pylab, results, what_to_plot_res, colors, xwhat, ywhat,
                          marker=marker_res)
            set_axis_colors(pylab, color_resources, color_resources)

    qqueries = [ [ x ] for x in queries]            
    for xwhat, ywhat in itertools.combinations(what_to_plot_fun, 2):
        name = '%s_%s' % (xwhat, ywhat)
        with r.plot(name) as pylab:
            with figure_style1(pylab):                    
                plot_axis(pylab, qqueries, what_to_plot_fun, colors, xwhat, ywhat,
                          marker=marker_fun)
            set_axis_colors(pylab, color_functions, color_functions)


    for xwhat in what_to_plot_fun:
        for ywhat in what_to_plot_res:
            name = '%s_%s' % (xwhat, ywhat)
            with r.plot(name) as pylab:
                with figure_style1(pylab):
                    for fun, res, color in zip(qqueries, results, colors):
                        x = to_numpy_array(what_to_plot_fun, fun)[xwhat]
                        y = to_numpy_array(what_to_plot_res, res)[ywhat]
                        if len(y) == 0:  # unfeasible
                            pylab.plot(x, 0, 'x', color='black')
                        elif len(x) == 1 and len(y) > 1:
                            xs = [x[0]] * len(y)
                            pylab.plot(xs, y, marker_joint, color=color)
                        else:
                            print x, y
                            pylab.plot(x, y, marker_joint, color=color)
                set_axis_colors(pylab, color_functions, color_resources)

                pylab.xlabel(axis_label(what_to_plot_fun, xwhat))
                pylab.ylabel(axis_label(what_to_plot_res, ywhat))
Пример #3
0
    def get_value(data, field):
        for res in data['results']:
            a = to_numpy_array({field: 'kg'}, res)

            if len(a):
                a = min(a[field])
            else:
                a = None
            yield a
Пример #4
0
    def get_value(data, field):
        for res in data['results']:
            a = to_numpy_array({field: 'kg'}, res)

            if len(a):
                a = min(a[field])
            else:
                a = None
            yield a
Пример #5
0
def plot_axis(pylab, results, what_to_plot, colors, xwhat, ywhat, marker):

    for res, color in zip(results, colors):
        a = to_numpy_array(what_to_plot, res)
        x = a[xwhat]
        y = a[ywhat]
        pylab.plot(x, y, marker, color=color)

    pylab.xlabel(axis_label(what_to_plot, xwhat))
    pylab.ylabel(axis_label(what_to_plot, ywhat))
Пример #6
0
def plot_axis(pylab, results, what_to_plot, colors, xwhat, ywhat, marker):

    for res, color in zip(results, colors):
        a = to_numpy_array(what_to_plot, res)
        x = a[xwhat]
        y = a[ywhat]
        pylab.plot(x, y, marker, color=color)

    pylab.xlabel(axis_label(what_to_plot, xwhat))
    pylab.ylabel(axis_label(what_to_plot, ywhat))