Ejemplo n.º 1
0
def init_figures(issplit, isvector, naxes, nplots):
    """
    initialize figures and set up backends

    issplit: true if we're making separate vector and raster figures
    isvector: true if we're making vector lines
    naxes: number of axes, used for sizing
    nplots: number of subplots, used for sizing
    """
    figsize = (3 + 0.6 * naxes, 2 + (4 / 3) * nplots)
    #    figsize = (3 + 0.6 * naxes, 2 + (10/3) * nplots)
    if issplit:
        raster = matplotlib.figure.Figure(figsize=figsize)
        agg.FigureCanvasAgg(raster)
        vector = matplotlib.figure.Figure(figsize=figsize)
        svg.FigureCanvasSVG(vector)
    elif isvector:
        vector = matplotlib.figure.Figure(figsize=figsize)
        svg.FigureCanvasSVG(vector)
        raster = vector
    else:
        raster = matplotlib.figure.Figure(figsize=figsize)
        agg.FigureCanvasAgg(raster)
        vector = raster

    return raster, vector
def cli():
    args = get_args()
    algos = args.algos.split(",")
    print algos
    problems = args.problems.split(",")
    print problems
    nalgos = len(algos)
    nproblems = len(problems)

    fig = matplotlib.figure.Figure(figsize=(nalgos * 3, nproblems * 2.2))
    if args.svg:
        svg.FigureCanvasSVG(fig)
    else:
        agg.FigureCanvasAgg(fig)
    keywords = {}
    keywords["stat"] = args.stat
    keywords["metric"] = args.metric
    keywords["dirname"] = args.stats_directory
    if args.cbar_context_low is not None:
        keywords["context_l"] = args.cbar_context_low
    if args.cbar_context_high is not None:
        keywords["context_h"] = args.cbar_context_high
    if args.best is not None:
        keywords["best"] = args.best
    if args.worst is not None:
        keywords["worst"] = args.worst

    controlmaps(fig, algos, problems, args.params_dir, **keywords)
    fig.subplots_adjust(right=0.88, wspace=0.03, hspace=0.3)

    fig.savefig(args.output_file)
Ejemplo n.º 3
0
def make_image(func, data, fig_format='svg', **kwds):
    content_type = {'png': 'image/png', 'svg': 'image/svg+xml'}[fig_format]

    fig = __figs.get(tuple(kwds.items()), None)
    if fig is None:
        fig = mpl.figure.Figure(**kwds)
        canvas = backend_svg.FigureCanvasSVG(fig)
        __figs[tuple(kwds.items())] = fig
    else:
        fig.clear()
    func(fig, data)
    buff = io.BytesIO()
    fig.savefig(buff, format=fig_format)
    img = buff.getvalue()
    height = int(fig.get_dpi() * fig.get_figheight())
    width = int(fig.get_dpi() * fig.get_figwidth())
    return img, width, height
Ejemplo n.º 4
0
def cli():
    args = get_args()
    table = pandas.read_table(args.table, sep=' ')
    fig = matplotlib.figure.Figure()
    if args.vector:
        svg.FigureCanvasSVG(fig)
    else:
        agg.FigureCanvasAgg(fig)

    algos = args.algos.split(",")
    barchart_figure(fig,
                    table,
                    algos,
                    args.key,
                    barwidth=args.width,
                    barheight=args.height)
    fig.savefig(args.output)
Ejemplo n.º 5
0
===========================================================
statusplot.py
"""
import pandas
import matplotlib
import matplotlib.backends.backend_svg as svg
from numpy import array

status = pandas.read_table("status.txt", index_col=0)
grouped = status.groupby(["alg", "dv", "obj", "eps"])
status["progress"] = status.apply(lambda row: float(row["sets"]) / row["needed"], axis = 1)
means = grouped["progress"].mean()
width, height = matplotlib.figure.figaspect(0.2)
print width, height
fig = matplotlib.figure.Figure(figsize = (width, height))
svg.FigureCanvasSVG(fig)
colors = means.apply(lambda progress: [[0.7, 0.7, 0.2],[0.2,0.8,0.2]][int(progress)])
subplots = ["Borg", "eMOEA", "eNSGAII", "NSGAII"]
for ii in range(len(subplots)):
    alg = subplots[ii]
    ax = fig.add_subplot(1,4,ii+1)
    co = array(list(colors.ix[alg].values))
    ax.barh(range(6), means.ix[alg].values, color=co)
    ax.set_yticks([])
    ax.set_yticks([0.4 + x for x in range(6)])
    ax.set_yticklabels(["","","","","",""])
    ax.set_xticks([0, 0.25, 0.5, 0.75, 1.0])
    ax.set_xticklabels(["0", "", "0.5", "", "1"])
    ax.set_title(alg)

labels = means.ix["Borg"].index.values