Exemplo n.º 1
0
    def plot(self, directory, entries, samples, nr_samples, verbose=False):
        from matplotlib import use as muse
        muse('Agg')
        from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
        from matplotlib.figure import Figure
        from matplotlib.ticker import FuncFormatter, FixedFormatter, LinearLocator
        from matplotlib.mlab import std as std_deviation
        from matplotlib.mlab import mean
        from time import asctime

        yfont = {
            'fontname': 'Bitstream Vera Sans',
            'color': 'r',
            'fontsize': 8
        }

        xfont = {
            'fontname': 'Bitstream Vera Sans',
            'color': 'b',
            'fontsize': 8
        }

        titlefont = {
            'fontname': 'Bitstream Vera Sans',
            'color': 'g',
            'fontweight': 'bold',
            'fontsize': 10
        }

        inches = 0.00666667
        width = 950 * inches
        height = 680 * inches

        fig = Figure(figsize=(width, height))
        canvas = FigureCanvas(fig)
        ax = fig.add_subplot(111)
        ax.grid(False)
        xtickfontsize = 5
        ytickfontsize = 5

        plot_type = 'b-'
        field_mean = mean(samples)
        yaxis_plot_fmt = FuncFormatter(pylab_formatter_ms)

        ax.plot(entries, samples, "b-")

        ax.set_xlabel("samples", xfont)
        ax.set_ylabel("time", yfont)

        for label in ax.get_xticklabels():
            label.set(fontsize=xtickfontsize)
        for label in ax.get_yticklabels():
            label.set(fontsize=ytickfontsize)

        ax.yaxis.set_major_formatter(yaxis_plot_fmt)
        ax.set_title("%d %s samples (%s)" % (nr_samples, self.name, asctime()),
                     titlefont)
        canvas.print_figure("%s/methods/%s.png" % (directory, self.name))
        del fig, canvas, ax
Exemplo n.º 2
0
	def plot(self, directory, entries, samples, nr_samples, verbose = False):
		from matplotlib import use as muse
		muse('Agg')
		from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
		from matplotlib.figure import Figure
		from matplotlib.ticker import FuncFormatter, FixedFormatter, LinearLocator
		from matplotlib.mlab import std as std_deviation
		from matplotlib.mlab import mean
		from time import asctime

		yfont = { 'fontname'   : 'Bitstream Vera Sans',
			  'color'      : 'r',
			  'fontsize'   : 8 }

		xfont = { 'fontname'   : 'Bitstream Vera Sans',
			  'color'      : 'b',
			  'fontsize'   : 8 }

		titlefont = { 'fontname'   : 'Bitstream Vera Sans',
			      'color'      : 'g',
			      'fontweight' : 'bold',
			      'fontsize'   : 10 }

		inches = 0.00666667
		width  = 950 * inches
		height = 680 * inches

		fig = Figure(figsize = (width, height))
		canvas = FigureCanvas(fig)
		ax = fig.add_subplot(111)
		ax.grid(False)
		xtickfontsize = 5
		ytickfontsize = 5

		plot_type = 'b-'
		field_mean = mean(samples)
		yaxis_plot_fmt = FuncFormatter(pylab_formatter_ms)
			
		ax.plot(entries, samples, "b-")

		ax.set_xlabel("samples", xfont)
		ax.set_ylabel("time", yfont)

		for label in ax.get_xticklabels():
			label.set(fontsize = xtickfontsize)
		for label in ax.get_yticklabels():
			label.set(fontsize = ytickfontsize)

		ax.yaxis.set_major_formatter(yaxis_plot_fmt)
		ax.set_title("%d %s samples (%s)" % (nr_samples, self.name, asctime()), titlefont)
		canvas.print_figure("%s/methods/%s.png" % (directory, self.name))
		del fig, canvas, ax
Exemplo n.º 3
0
def plot_field(name,
               directory,
               tstamps,
               samples,
               nr_samples,
               plot_fmt=None,
               table=None,
               verbose=False):
    global current_plot_fmt

    from matplotlib import use as muse
    muse('Agg')
    from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
    from matplotlib.figure import Figure
    from matplotlib.ticker import FuncFormatter, FixedFormatter, LinearLocator
    from matplotlib.mlab import std as std_deviation
    from matplotlib.mlab import mean
    from time import asctime

    yfont = {'fontname': 'Bitstream Vera Sans', 'color': 'r', 'fontsize': 8}

    xfont = {'fontname': 'Bitstream Vera Sans', 'color': 'b', 'fontsize': 8}

    titlefont = {
        'fontname': 'Bitstream Vera Sans',
        'color': 'g',
        'fontweight': 'bold',
        'fontsize': 10
    }

    inches = 0.00666667
    width = 950 * inches
    height = 680 * inches

    fig = Figure(figsize=(width, height))
    canvas = FigureCanvas(fig)
    ax = fig.add_subplot(111)
    ax.grid(False)
    xtickfontsize = 5
    ytickfontsize = 5

    current_plot_fmt = plot_fmt
    field_mean = None

    plot_type = 'b-'
    if current_plot_fmt == "filter_dev":
        std = std_deviation(samples) * 2
        if verbose:
            print("filter_dev(%s) std=%d" % (name, std))
        for i in range(nr_samples):
            if samples[i] > std:
                if verbose:
                    print("%s: filtering out %d" % (name, samples[i]))
                samples[i] = 0
        field_mean = mean(samples)
        yaxis_plot_fmt = FuncFormatter(pylab_formatter)
    elif current_plot_fmt == "table":
        ax.grid(True)
        plot_type = 'bo-'
        max_value = max(samples)
        without_zero = 1
        if table.has_key(0):
            without_zero = 0
            max_value += 1
        ax.yaxis.set_major_locator(LinearLocator(max_value))
        tstamps = range(nr_samples)
        seq = [" "] * max_value
        for key in table.keys():
            if key in samples:
                seq[key - without_zero] = "%s(%d)" % (table[key], key)
        ytickfontsize = 4
        yaxis_plot_fmt = FixedFormatter(seq)
    else:
        field_mean = mean(samples)
        yaxis_plot_fmt = FuncFormatter(pylab_formatter)

    ax.plot(tstamps, samples, plot_type)

    ax.set_xlabel("time", xfont)
    yname = name
    if field_mean:
        yname += " (mean=%s)" % pylab_formatter(field_mean)
    ax.set_ylabel(yname, yfont)

    for label in ax.get_xticklabels():
        label.set(fontsize=xtickfontsize)
    for label in ax.get_yticklabels():
        label.set(fontsize=ytickfontsize)

    ax.yaxis.set_major_formatter(yaxis_plot_fmt)
    ax.set_title("%d %s samples (%s)" % (nr_samples, name, asctime()),
                 titlefont)
    canvas.print_figure("%s/%s.png" % (directory, name))
    del fig, canvas, ax
Exemplo n.º 4
0
# Description:
#       Generate dot graph from gdb backtracet data
# Author:
#       Tarun Sharma ([email protected])
# Date:
#       2019-01-19

import os
from matplotlib import use as muse
from copy import deepcopy
muse('Agg')
import sys
import pydotplus
import argparse
import pdb
from pprint import pprint as pp
import logging

logging.basicConfig(format='%(asctime)s %(message)s',
                    datefmt='%m/%d/%Y %I:%M:%S %p')
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)

HTML_SEP = '

'

# Make resulting SVG interactive
js_string = '''
<script>
<![CDATA[

        class Node {
Exemplo n.º 5
0
def plot_field(name, directory, tstamps, samples, nr_samples, plot_fmt = None,
	       table = None, verbose = False):
	global current_plot_fmt

	from matplotlib import use as muse
	muse('Agg')
	from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
	from matplotlib.figure import Figure
	from matplotlib.ticker import FuncFormatter, FixedFormatter, LinearLocator
	from matplotlib.mlab import std as std_deviation
	from matplotlib.mlab import mean
	from time import asctime

	yfont = { 'fontname'   : 'Bitstream Vera Sans',
		  'color'      : 'r',
		  'fontsize'   : 8 }

	xfont = { 'fontname'   : 'Bitstream Vera Sans',
		  'color'      : 'b',
		  'fontsize'   : 8 }

	titlefont = { 'fontname'   : 'Bitstream Vera Sans',
		      'color'      : 'g',
		      'fontweight' : 'bold',
		      'fontsize'   : 10 }

	inches = 0.00666667
	width  = 950 * inches
	height = 680 * inches

	fig = Figure(figsize = (width, height))
	canvas = FigureCanvas(fig)
	ax = fig.add_subplot(111)
	ax.grid(False)
	xtickfontsize = 5
	ytickfontsize = 5

	current_plot_fmt = plot_fmt
	field_mean = None

	plot_type = 'b-'
	if current_plot_fmt == "filter_dev":
		std = std_deviation(samples) * 2
		if verbose:
			print "filter_dev(%s) std=%d" % (name, std)
		for i in range(nr_samples):
			if samples[i] > std:
				if verbose:
					print "%s: filtering out %d" % (name, samples[i])
				samples[i] = 0
		field_mean = mean(samples)
		yaxis_plot_fmt = FuncFormatter(pylab_formatter)
	elif current_plot_fmt == "table":
		ax.grid(True)
		plot_type = 'bo-'
		max_value = max(samples)
		without_zero = 1
		if table.has_key(0):
			without_zero = 0
			max_value += 1
		ax.yaxis.set_major_locator(LinearLocator(max_value))
		tstamps = range(nr_samples)
		seq = [ " " ] * max_value
		for key in table.keys():
			if key in samples:
				seq[key - without_zero] = "%s(%d)" % (table[key], key)
		ytickfontsize = 4
		yaxis_plot_fmt = FixedFormatter(seq)
	else:
		field_mean = mean(samples)
		yaxis_plot_fmt = FuncFormatter(pylab_formatter)
		
	ax.plot(tstamps, samples, plot_type)

	ax.set_xlabel("time", xfont)
	yname = name
	if field_mean:
		yname += " (mean=%s)" % pylab_formatter(field_mean)
	ax.set_ylabel(yname, yfont)

	for label in ax.get_xticklabels():
		label.set(fontsize = xtickfontsize)
	for label in ax.get_yticklabels():
		label.set(fontsize = ytickfontsize)

	ax.yaxis.set_major_formatter(yaxis_plot_fmt)
	ax.set_title("%d %s samples (%s)" % (nr_samples, name, asctime()), titlefont)
	canvas.print_figure("%s/%s.png" % (directory, name))
	del fig, canvas, ax