def create_plot_objects_for_group(phase_name, group_name, min_timestamp, max_timestamp, make_legend): """ Create and format two Boomslang plot objects: one for the time series plot, and the other for a CDF of the y-axis values in the time series. min and max timestamps are assumed to be adjusted with timestamp_adjuster (see below) before being passed as arguments """ time_series_plot = Plot() time_series_plot.setXLimits( 0, (max_timestamp - min_timestamp) / 1000000.0) time_series_plot.setXLabel("Time (s)") time_series_plot.setYLabel(group_name) cdf_plot = Plot() cdf_plot.setXLabel(group_name) cdf_plot.setYLabel("CDF") for plot in [time_series_plot, cdf_plot]: if make_legend: plot.hasLegend(labelSize = 8, columns=2) plot.setTitle("Phase: %(phase_name)s, %(group_name)s" % {"phase_name" : phase_name, "group_name" : group_name}) for color in ["red", "green", "blue", "teal", "orange", "purple", "brown", "black"]: plot.addLineColor(color) for style in ["solid", "dashed", "dotted"]: plot.addLineStyle(style) return (time_series_plot, cdf_plot)
def histogram_plot(experiment_log_dir, plot_spec_string, output_filename, has_legend, x_limit, verbose): queries = [ plot_utils.plot_spec_string_to_query(plot_spec_string, 0, "HIST")] plot_data = metaprogram_utils.process_queries( queries, experiment_log_dir, verbose) if "plot_points" not in plot_data: warnings.warn("No data to plot!") return histogram_data = plot_data["plot_points"][0] cumulative_histogram = {} layout = PlotLayout() layout.dpi = 250 for stat_name in histogram_data: plot = Plot() plot.setTitle(stat_name) if has_legend: plot.hasLegend(labelSize=8) if x_limit is not None: plot.setXLimits(0, x_limit) style_plot(plot, stat_name) for key, points in sorted(histogram_data[stat_name].items()): for size, count in itertools.izip(points["bin"], points["count"]): if size not in cumulative_histogram: cumulative_histogram[size] = 0 cumulative_histogram[size] += count line = Line() line.stepFunction("pre") line.label = str(key) line.xValues = points["bin"] line.yValues = points["count"] plot.add(line) layout.addPlot(plot) cumulative_plot = Plot() if x_limit is not None: cumulative_plot.setXLimits(0, x_limit) cumulative_plot.setTitle("Cumulative Histogram for " + stat_name) style_plot(cumulative_plot, stat_name) line = Line() line.stepFunction("pre") line.xValues = sorted(cumulative_histogram.keys()) line.yValues = [cumulative_histogram[key] for key in line.xValues] cumulative_plot.add(line) layout.addPlot(cumulative_plot) layout.save(output_filename)
def constructImage(self): plot = Plot() # Uneven error bars line = Line() line.xValues = [6,10,4,0,8,2,12] line.yValues = [50,90,30,10,70,20,110] line.yMins = [y - 30 for y in line.yValues] line.yMaxes = [y + 50 for y in line.yValues] line.label = "Asymmetric Errors" line.color = "red" # Even error bars line2 = Line() line2.xValues = [1,5,3,9,7,11] line2.yValues = [100, 120, 110, 140, 130, 150] line2.color = "blue" line2.label = "Symmetric Errors" line2.yErrors = [5,25,15,45,35,55] plot.add(line) plot.add(line2) plot.setXLabel("X Label") plot.setYLabel("Y Label") plot.hasLegend() plot.setXLimits(-1, 13) plot.save(self.imageName)
def generatePlot(stepType): line = Line() line.xValues = xVals line.yValues = yVals line.marker = 'o' line.stepFunction(stepType) plot = Plot() plot.add(line) plot.setTitle(r'"%s" Steps' % (stepType)) plot.setXLimits(0, 6) plot.setYLimits(0, 6) return plot
def constructImage(self): line = Line() line.xValues = numpy.arange(0, 150, 0.01) line.yValues = numpy.cos(.02 * numpy.pi * line.xValues) plot = Plot() plot.add(line) plot.setXLimits(0, 150) plot.setYLimits(-1, 1) plot.setXLabel("X") plot.setYLabel("cos(X)") splitPlots = plot.split(2) layout = PlotLayout() layout.width = 2 layout.addPlot(plot, grouping="unsplit") for s in splitPlots: layout.addPlot(s, grouping="splits") layout.save(self.imageName)
def constructImage(self): line1 = Line() line2 = Line() line3 = Line() line1.xValues = range(0,10) line1.yValues = [2,5,2,3,2,2,1,0,1,0] line2.xValues = range(0,10) line2.yValues = [3,1,2,3,2,1,5,3,1,7] line3.xValues = range(0,10) line3.yValues = [2,1,3,1,3,4,1,4,5,0] stack = StackedLines() stack.addLine(line1, "red") stack.addLine(line2, "green") stack.addLine(line3, "blue") plot = Plot() plot.setYLimits(0, 7) plot.setXLimits(0, 9) plot.add(stack) plot.save(self.imageName)
def create_plot_objects_for_group(phase_name, group_name, min_timestamp, max_timestamp, make_legend): """ Create and format two Boomslang plot objects: one for the time series plot, and the other for a CDF of the y-axis values in the time series. min and max timestamps are assumed to be adjusted with timestamp_adjuster (see below) before being passed as arguments """ time_series_plot = Plot() time_series_plot.setXLimits(0, (max_timestamp - min_timestamp) / 1000000.0) time_series_plot.setXLabel("Time (s)") time_series_plot.setYLabel(group_name) cdf_plot = Plot() cdf_plot.setXLabel(group_name) cdf_plot.setYLabel("CDF") for plot in [time_series_plot, cdf_plot]: if make_legend: plot.hasLegend(labelSize=8, columns=2) plot.setTitle("Phase: %(phase_name)s, %(group_name)s" % { "phase_name": phase_name, "group_name": group_name }) for color in [ "red", "green", "blue", "teal", "orange", "purple", "brown", "black" ]: plot.addLineColor(color) for style in ["solid", "dashed", "dotted"]: plot.addLineStyle(style) return (time_series_plot, cdf_plot)
def histogram_plot(experiment_log_dir, plot_spec_string, output_filename, has_legend, x_limit, verbose): queries = [ plot_utils.plot_spec_string_to_query(plot_spec_string, 0, "HIST") ] plot_data = metaprogram_utils.process_queries(queries, experiment_log_dir, verbose) if "plot_points" not in plot_data: warnings.warn("No data to plot!") return histogram_data = plot_data["plot_points"][0] cumulative_histogram = {} layout = PlotLayout() layout.dpi = 250 for stat_name in histogram_data: plot = Plot() plot.setTitle(stat_name) if has_legend: plot.hasLegend(labelSize=8) if x_limit is not None: plot.setXLimits(0, x_limit) style_plot(plot, stat_name) for key, points in sorted(histogram_data[stat_name].items()): for size, count in itertools.izip(points["bin"], points["count"]): if size not in cumulative_histogram: cumulative_histogram[size] = 0 cumulative_histogram[size] += count line = Line() line.stepFunction("pre") line.label = str(key) line.xValues = points["bin"] line.yValues = points["count"] plot.add(line) layout.addPlot(plot) cumulative_plot = Plot() if x_limit is not None: cumulative_plot.setXLimits(0, x_limit) cumulative_plot.setTitle("Cumulative Histogram for " + stat_name) style_plot(cumulative_plot, stat_name) line = Line() line.stepFunction("pre") line.xValues = sorted(cumulative_histogram.keys()) line.yValues = [cumulative_histogram[key] for key in line.xValues] cumulative_plot.add(line) layout.addPlot(cumulative_plot) layout.save(output_filename)
#!/usr/bin/env python from boomslang import Plot, Line, PlotLayout import numpy line = Line() line.xValues = numpy.arange(0, 150, 0.01) line.yValues = numpy.cos(.02 * numpy.pi * line.xValues) plot = Plot() plot.add(line) plot.setXLimits(0, 150) plot.setYLimits(-1, 1) plot.setXLabel("X") plot.setYLabel("cos(X)") splitPlots = plot.split(2) layout = PlotLayout() layout.width = 2 layout.addPlot(plot, grouping="unsplit") for s in splitPlots: layout.addPlot(s, grouping="splits") layout.save("split.png")