def plot(data, xlabel, ylabel, filename):
    opts = tsg_plot.PlotOptions()
    attribute_dict = {
        "plot_type":
        "line",
        "data":
        data,
        "labels": ["little", "big"],
        "legend_ncol":
        2,
        "file_name":
        filename,
        "figsize": (3.5, 1.5),
        "fontsize":
        8,
        "xlabel":
        xlabel,
        "ylabel":
        ylabel,
        "colors": [
            tsg_plot.colors['blue3'][2],
            tsg_plot.colors['qualitative_paired'][5]
        ],
        "rotate_labels":
        True,
        "rotate_labels_angle":
        -30,
    }
    for k, v in attribute_dict.iteritems():
        setattr(opts, k, v)
    tsg_plot.add_plot(opts)
def plot_em(data, benchmarks, metrics, policies, filename):
    """
  Plot energy and deadline misses.
  """
    # Common options
    opts = plot_common(data, benchmarks, metrics, policies, filename)

    # Colors based on number of configurations
    if len(policies) == 6:
        opts.colors = tsg_plot.colors['blue3'] * 2
        opts.hatch = [''] * 3 + ['////'] * 3
    elif len(policies) == 2:
        opts.colors = [
            tsg_plot.colors['blue3'][0], tsg_plot.colors['blue3'][2]
        ]
    else:
        raise Exception("Unsuported number of policies = %d" % len(policies))

    opts.file_name = filename.split('.')[0] + "_em.pdf"

    for metric in ["energy", "deadline_misses"]:
        if metric == "energy":
            opts.ylabel = "Energy [%]"
        elif metric == "deadline_misses":
            opts.ylabel = "Misses [%]"
        # Restructure data
        metric_data = data[metric]
        opts.data = []
        for policy in policies:
            opts.data.append(metric_data[policy])
            opts.labels[1].append(policy_to_label(policy))
        opts.data = numpy.array(opts.data).T

        # Use one legend for both plots
        if opts.plot_idx == 1:
            opts.legend_enabled = True
        else:
            opts.legend_enabled = False

        tsg_plot.add_plot(opts)
示例#3
0
def plot(data):
  opts = tsg_plot.PlotOptions()
  opts.data = data

  attribute_dict = \
      {
          'labels' : ['line 1', 'line 2', 'line 3'],
          'show' : False,
          'file_name' : 'example_line.pdf',
          'plot_type' : 'line',
          'figsize' : (7.0, 3.0),
          'legend_ncol' : 3,
          'xlabel' : 'x',
          'ylabel' : 'f(x)',
          'symbols' : ['.']*3,
          'linestyles' : ['-', '', '--'],
          'markersize' : 8,
      }

  for name, value in attribute_dict.iteritems():
    setattr( opts, name, value )
  tsg_plot.add_plot( opts )
def plot_core_counts(data, benchmarks, metrics, policies, filename):
    """
  Plot number of core switches and number of jobs on big core.
  """
    # Common options
    opts = plot_common(data, benchmarks, metrics, policies, filename)

    # Colors based on number of configurations
    if len(policies) == 6:
        opts.colors = tsg_plot.colors['blue3']
        opts.hatch = [''] * 3
    elif len(policies) == 2:
        opts.colors = [tsg_plot.colors['blue3'][2]]
    else:
        raise Exception("Unsuported number of policies = %d" % len(policies))

    opts.file_name = filename.split('.')[0] + "_counts.pdf"

    for metric in ["switch_count", "big_count"]:
        if metric == "switch_count":
            opts.ylabel = "Core Switches [%]"
        elif metric == "big_count":
            opts.ylabel = "Big Core Jobs [%]"
        # Restructure data
        metric_data = data[metric]
        opts.data = []
        for policy in policies:
            if "biglittle" in policy:
                opts.data.append(metric_data[policy])
                opts.labels[1].append(policy_to_label(policy))
        opts.data = numpy.array(opts.data).T

        # Use one legend for both plots
        if opts.plot_idx == 1:
            opts.legend_enabled = True
        else:
            opts.legend_enabled = False

        tsg_plot.add_plot(opts)
示例#5
0
def plot(data, filename):
    # Set up plotting options
    opts = tsg_plot.PlotOptions()
    # Benchmarks
    cat = data['benchmarks']
    # Overheads
    subcat = data['policies']
    opts.data = data['data']
    opts.labels = [cat, subcat]

    attribute_dict = \
        {
            'plot_type' : 'bar',
            'show' : False,
            'file_name' : filename,
            'paper_mode' : True,
            'figsize' : (3.5, 2.0),
            'ylabel' : 'Overhead Difference [%]',
            'legend_ncol' : 6,
            'legend_handlelength' : 1.0,
            'legend_columnspacing' : 0.8,
            'legend_handletextpad' : 0.5,
            'legend_bbox' : [-0.05, 1.05, 1, 0.1],
            'rotate_labels' : True,
            'rotate_labels_angle' : -45,
            'fontsize' : 8,
            'bar_width' : 0.5,
            'yrange' : [-50, 50],

            #'colors' : ['#deebf7', '#9acae1', '#3182bd', '#deebf7', '#9ecae1', '#3182bd'],
            'colors' : ['#deebf7', '#3182bd'],

        }
    for name, value in attribute_dict.iteritems():
        setattr(opts, name, value)

    # Plot
    tsg_plot.add_plot(opts)
def plot(data, labels, kk):
    opts.labels = labels

    attribute_dict = \
        {
            'bar_width' : 0.7,
            'figsize' : (7.0, 2),
            'fontsize' : 4,
            'labels_fontsize' : 4,
            'colors' : ["#a6cee3", "#1f78b4", "#b2df8a", "#33a02c", "#fb9a99", "#e31a1c", "#ff7f00", "#cab2d6", "#6a3d9a", "#ffff99", "#b15928", "#fdbf6f"],
            'paper_mode' : True,
            'show' : False,
            'paper_mode' : True,
            'legend_ncol' : 2,
            'rotate_labels' : True,
            'rotate_labels_angle' : -45,
            'num_rows' : 1,
            'num_cols' : 3
        }

    opts.xlabel = big_little
    if kk == 0 :
        opts.ylabel = "energy [%]"
        opts.legend_enabled = True
    elif kk == 1 :
        opts.ylabel = "deadline_misses [%]"
        opts.legend_enabled = False
        #opts.file_name = ""+big_little+"_"+benchmarks+".pdf"
    elif kk == 2:
        opts.ylabel = "tardiness [us]"
        opts.legend_enabled = False
        opts.file_name = ""+big_little+"_"+benchmarks+".pdf"
    opts.data = data
    for name, value in attribute_dict.iteritems():
        setattr( opts, name, value )

    # Plot
    tsg_plot.add_plot( opts )
def plot(data, labels):
    opts = tsg_plot.PlotOptions()

    opt_dict = \
        {
            "data" : data,
            "labels" : labels,
            "plot_type" : "line",
            "figsize" : (7, 2.5),
            "fontsize" : 8,
            "file_name" : "plot_prediction.pdf",
            "symbols" : ['']*10,
            "legend_ncol" : 4,
            "xlabel" : "Job",
            "ylabel" : "Execution Time [us]",
            #"colors" : ["#000000", "#e31a1c"]
            "colors" : tsg_plot.colors["qualitative"],

            "linestyles" : ['-', '-', '--', '--'],
        }
    for k, v in opt_dict.iteritems():
        setattr(opts, k, v)
    tsg_plot.add_plot(opts)
示例#8
0
def plot(data):
    opts = tsg_plot.PlotOptions()
    opts.data = []
    opts.labels = [[], []]
    opts.colors = []
    color_keys = []
    for (k, v) in data['data'].iteritems():
        opts.data.append(v)
        opts.labels[1].append(k)

        # Use same colors based on key
        # color_key = k.split("_")[-2]
        # if not color_key in color_keys:
        #   color_keys.append(color_key)
        # opts.colors.append(colors[color_keys.index(color_key)])
    opts.colors = colors

    attribute_dict = \
        {
            'show' : False,
            'file_name' : 'scatter.pdf',
            'plot_type' : 'scatter',
            'paper_mode' : True,
            'figsize' : (7.0, 3.5),
            'legend_ncol' : 3,
            'ylabel' : 'Deadline Misses [%]',
            'xlabel' : 'Energy [%]',
            'fontsize' : 8,
            'title' : '',
            #'yrange' : [0, 3],

            'symbols' : ['o']*15
        }

    for name, value in attribute_dict.iteritems():
        setattr(opts, name, value)
    tsg_plot.add_plot(opts)
f = open(filename, 'r')
data = []
subplot_index = 1
for line in f:
    if line != "\n":
        data.append(line.strip())
    # End of block of data, plot it
    elif data:
        # Parse data
        metric = data[0]
        benchmarks = data[1].split(',')[1:]
        policies = [d.split(',')[0] for d in data[2:]]
        data = [d.split(',')[1:] for d in data[2:]]
        data = [[100 * float(dd) for dd in d] for d in data]
        data = numpy.array(data).transpose()
        # Add to options
        opts.data = data
        opts.labels = [benchmarks, map(policy_to_label, policies)]
        opts.ylabel = metric.replace('_', ' ') + " [%]"
        # Only show legend in middle plot
        #if opts.plot_idx == 1:
        #  opts.legend_enabled = True
        #else:
        #  opts.legend_enabled = False
        # Plot
        tsg_plot.add_plot(opts)

        # Reset for next metric
        data = []
f.close()
示例#10
0
cat = []
data = []
for line in f:
  ls = line.split(',')
  cat.append(ls[0])
  data.append([float(x) for x in ls[1:]])
f.close()

# Set up plotting options
opts = tsg_plot.PlotOptions()
opts.data = data
opts.labels = [cat, subcat]

attribute_dict = \
    {
        'show' : False,
        'file_name' : 'example_stacked_bar.pdf',
        'plot_type' : 'stacked_bar',
        'figsize' : (3.5, 2.5),
        'xlabel' : 'Functions',
        'ylabel' : 'Value',
        'legend_ncol' : 3,
        'rotate_labels' : True,
        'rotate_labels_angle' : -30
    }
for name, value in attribute_dict.iteritems():
  setattr( opts, name, value )

# Plot
tsg_plot.add_plot( opts )