Uses sample code from http://matplotlib.org/1.2.1/examples/api/barchart_demo.html
423409
def draw_bar_chart():
    
    N = 5
    menMeans = (20, 35, 30, 35, 27)
    menStd = (2, 3, 4, 1, 2)

    ind = numpy.arange(N)
    width = 0.35

    fig = pyplot.figure()
    ax = fig.add_subplot(111)
    rects1 = ax.bar(ind, menMeans, width, color='r', yerr=menStd)

    womenMeans = (25, 32, 34, 20, 25)
    womenStd = (3, 5, 2, 3, 3)
    rects2 = ax.bar(ind+width, womenMeans, width, color='y', yerr=womenStd)

    ax.set_ylabel('Scores')
    ax.set_title('Scores by group and color')
    ax.set_xticks(ind+width)
    ax.set_xticklabels(('G1', 'G2', 'G3', 'G4', 'G5'))

    ax.legend((rects1[0], rects2[0]), ('Red', 'Yellow'))

    def autolabel(rects):
        for rect in rects:
            height = rect.get_height()
            ax.text(rect.get_x()+rect.get_width()/2., 1.05*height, '%d' % int(height),
                    ha='center', va='bottom')

    autolabel(rects1)
    autolabel(rects2)
    pyplot.savefig(bars_filename)
1113903
def xerrorbar(self, canvas, X, Y, error, color=None, label=None, **kwargs):
        
        raise NotImplementedError("Implement all plot functions in AbstractPlottingLibrary in order to use your own plotting library")
1271966
function () {
            var chart = this,
              axes = chart.axes,
              renderer = chart.renderer,
              options = chart.options;

            // Title
            chart.setTitle();


            // Legend
            chart.legend = new Legend(chart, options.legend);

            chart.getStacks(); // render stacks

            // Get margins by pre-rendering axes
            // set axes scales
            each(axes, function (axis) {
                axis.setScale();
            });

            chart.getMargins();

            chart.maxTicks = null; // reset for second pass
            each(axes, function (axis) {
                axis.setTickPositions(true); // update to reflect the new margins
                axis.setMaxTicks();
            });
            chart.adjustTickAmounts();
            chart.getMargins(); // second pass to check for new labels


            // Draw the borders and backgrounds
            chart.drawChartBox();


            // Axes
            if (chart.hasCartesianSeries) {
                each(axes, function (axis) {
                    axis.render();
                });
            }

            // The series
            if (!chart.seriesGroup) {
                chart.seriesGroup = renderer.g('series-group')
                  .attr({ zIndex: 3 })
                  .add();
            }
            chart.renderSeries();

            // Labels
            chart.renderLabels();

            // Credits
            chart.showCredits(options.credits);

            // Set flag
            chart.hasRendered = true;

        }
815691
function slide14() {
		var slide = pptx.addNewSlide();
		slide.addNotes('API Docs: https://gitbrent.github.io/PptxGenJS/docs/api-charts.html');
		slide.addTable( [ [{ text:'Chart Examples: XY Scatter Chart', options:gOptsTextL },gOptsTextR] ], gOptsTabOpts );

		var arrDataScatter1 = [
			{ name:'X-Axis',    values:[0,1,2,3,4,5,6,7,8,9] },
			{ name:'Y-Value 1', values:[13, 20, 21, 25] },
			{ name:'Y-Value 2', values:[21, 22, 25, 49] }
		];
		var arrDataScatter2 = [
			{ name:'X-Axis',   values:[1, 2, 3, 4, 5, 6] },
			{ name:'Airplane', values:[33, 20, 51, 65, 71, 75] },
			{ name:'Train',    values:[99, 88, 77, 89, 99, 99] },
			{ name:'Bus',      values:[21, 22, 25, 49, 59, 69] }
		];
		var arrDataScatterLabels = [
		    { name:'X-Axis',    values:[1, 10, 20, 30, 40, 50] },
		    { name:'Y-Value 1', values:[11, 23, 31, 45], labels:['Red 1', 'Red 2', 'Red 3', 'Red 4'] },
		    { name:'Y-Value 2', values:[21, 38, 47, 59], labels:['Blue 1', 'Blue 2', 'Blue 3', 'Blue 4'] }
		];

		// TOP-LEFT
		var optsChartScat1 = { x:0.5, y:0.6, w:'45%', h:3,
			valAxisTitle        : "Renters",
			valAxisTitleColor   : "428442",
			valAxisTitleFontSize: 14,
			showValAxisTitle    : true,
			lineSize: 0,
			catAxisTitle        : "Last 10 Months",
			catAxisTitleColor   : "428442",
			catAxisTitleFontSize: 14,
			showCatAxisTitle    : true
		};
		slide.addChart( pptx.charts.SCATTER, arrDataScatter1, optsChartScat1 );

		// TOP-RIGHT
		var optsChartScat2 = { x:7.0, y:0.6, w:'45%', h:3,
			fill: 'f1f1f1',
			showLegend: true,
			legendPos : 'b',

			lineSize  : 8,
			lineSmooth: true,
			lineDataSymbolSize: 12,
			lineDataSymbolLineColor: 'FFFFFF',

			chartColors: [ COLOR_RED, COLOR_AMB, COLOR_GRN, COLOR_UNK ],
			chartColorsOpacity: 25
		};
		slide.addChart( pptx.charts.SCATTER, arrDataScatter2, optsChartScat2 );

		// BOTTOM-LEFT: (Labels)
		var optsChartScat3 = { x:0.5, y:4.0, w:'45%', h:3,
			fill: 'f2f9fc',
			//catAxisOrientation: 'maxMin',
			//valAxisOrientation: 'maxMin',
			showCatAxisTitle: false,
			showValAxisTitle: false,
			lineSize: 0,

			catAxisTitle        : "Data Point Labels",
			catAxisTitleColor   : "0088CC",
			catAxisTitleFontSize: 14,
			showCatAxisTitle    : true,

			// Data Labels
			showLabel             : true, // Must be set to true or labels will not be shown
			dataLabelFormatScatter: 'custom', // Can be set to `custom` (default), `customXY`, or `XY`.
		};
		slide.addChart( pptx.charts.SCATTER, arrDataScatterLabels, optsChartScat3 );

		// BOTTOM-RIGHT
		var optsChartScat4 = { x:7.0, y:4.0, w:'45%', h:3 };
		slide.addChart( pptx.charts.SCATTER, arrDataScatter2, optsChartScat4 );
	}
1064275
def create(plot_data, header, ploti, sample_config, out_file_base, outtype="png",
           title=None, size=None):
    
    if mpl is None or plt is None or sns is None:
        not_found = ", ".join([x for x in ['mpl', 'plt', 'sns'] if eval(x) is None])
        logger.info("No validation plot. Missing imports: %s" % not_found)
        return None
    mpl.use('Agg', force=True)

    if header:
        df = pd.DataFrame(plot_data, columns=header)
    else:
        df = plot_data
    df["aligner"] = [get_aligner(x, sample_config) for x in df["sample"]]
    df["bamprep"] = [get_bamprep(x, sample_config) for x in df["sample"]]
    floors = get_group_floors(df, cat_labels)
    df["value.floor"] = [get_floor_value(x, cat, vartype, floors)
                         for (x, cat, vartype) in zip(df["value"], df["category"], df["variant.type"])]
    out = []
    for i, prep in enumerate(df["bamprep"].unique()):
        out.append(plot_prep_methods(df, prep, i + ploti, out_file_base, outtype, title, size))
    return out
927813
def _get_chartjs_chart(self, xcol, ycol, chart_type, label=None, opts={},
                           style={}, options={}, **kwargs):
        
        try:
            xdata = list(self.df[xcol])
        except Exception as e:
            self.err(e, self._get_chartjs_chart,
                     "Can not get data for x field ", ycol)
            return
        if label is None:
            label = "Data"
        try:
            if type(ycol) != list:
                ydata = [dict(name=label, data=list(self.df[ycol]))]
            else:
                ydata = []
                for col in ycol:
                    y = {}
                    y["name"] = col
                    y["data"] = list(self.df[col])
                    ydata.append(y)
        except Exception as e:
            self.err(e, self._get_chartjs_chart,
                     "Can not get data for y field ", xcol)
            return
        try:
            slug = str(uuid.uuid4())
            html = chart.get(slug, xdata, ydata, label,
                             opts, style, chart_type, **kwargs)
            return html
        except Exception as e:
            self.err(e, self._get_chartjs_chart, "Can not get chart")
998312
def get_matplotlib_layout(widget, flag_toolbar=True):
    
    fig = plt.figure()
    canvas = FigureCanvas(fig)
    #        self.canvas.mpl_connect('button_press_event', self.on_plot_click)
    layout = QVBoxLayout(widget)
    if flag_toolbar:
        toolbar = NavigationToolbar2QT(canvas, widget)
        layout.addWidget(toolbar)
    layout.addWidget(canvas)
    a99.set_margin(layout, 0)

    return fig, canvas, layout
281820
def plot(self, key, part='re', scale='log', steps=50, legend=True, plotargs={}):
        
        try:
            import matplotlib.pyplot as plt
        except ImportError:
            raise ImportError("Please install matplotlib if you want to use the plot method")
        pdat = self.plotdata(key, part=part, scale=scale, steps=steps)
        plt.plot(*pdat, label=key, **plotargs)
        if scale == 'log':
            plt.xscale('log')
        if legend:
            plt.legend()
1262362
function example() {
  return function(data, render) {
    var output = '.. code-block:: javascript\n';
    var lines = render(data).split('\n');
    logger.debug('line-0', data);
    if (lines.length && lines[0].match(/^<caption>.*<\/caption>$/)) {
      output += '   :caption: ' + lines.shift().slice(9, -10) + '\n';
    }
    output += '\n';
    for (var i = 0; i < lines.length; i++) {
      output += '   ' + lines[i] + '\n';
    }
    return render(output);
  };
}
1010275
function drawItemBoxes(legend, barGroup) {
  legend.items.forEach(function(item, i) {
    var itemTop = itemY(legend, i);

    if (defined(item.imageUrl)) {
      barGroup.appendChild(
        svgElement(
          legend,
          "image",
          {
            "xlink:href": item.imageUrl,
            x: 0,
            y: itemTop,
            width: Math.min(item.imageWidth, legend.itemWidth + 4), // let them overlap slightly
            height: Math.min(item.imageHeight, legend.computedItemHeight + 4)
          },
          "item-icon"
        )
      );
      return;
    }

    if (defined(item.multipleColors)) {
      var columns = Math.sqrt(item.multipleColors.length) | 0;
      var rows = Math.ceil(item.multipleColors.length / columns) | 0;

      var colorCount = item.multipleColors.length;
      var index = 0;
      var y = itemTop;

      for (var row = 0; index < colorCount && row < rows; ++row) {
        var height =
          row === rows - 1
            ? legend.computedItemHeight - (y - itemTop)
            : legend.computedItemHeight / rows;

        var x = 0;
        for (var column = 0; index < colorCount && column < columns; ++column) {
          var color = item.multipleColors[index++];

          var width =
            column === columns - 1
              ? legend.itemWidth - x
              : legend.itemWidth / columns;

          barGroup.appendChild(
            svgElement(
              legend,
              "rect",
              {
                fill: color,
                x: x,
                y: y,
                width: width,
                height: height
              },
              "item-box"
            )
          );

          x += width;
        }

        y += height;
      }
    } else if (defined(item.color)) {
      const rectAttributes = {
        fill: item.color,
        x: 0,
        y: itemTop,
        width: legend.itemWidth,
        height: legend.computedItemHeight
      };
      if (defined(item.lineColor)) {
        rectAttributes.stroke = item.lineColor;
      }
      barGroup.appendChild(
        svgElement(legend, "rect", rectAttributes, "item-box")
      );
    }
  });
}
484270
def simple():
    
    MAX_VALUE = 100

    # Create our test progress bar
    bar = Bar(max_value=MAX_VALUE, fallback=True)

    bar.cursor.clear_lines(2)
     # Before beginning to draw our bars, we save the position
    #   of our cursor so we can restore back to this position before writing
    #   the next time.
    bar.cursor.save()
    for i in range(MAX_VALUE + 1):
        sleep(0.1 * random.random())
        # We restore the cursor to saved position before writing
        bar.cursor.restore()
        # Now we draw the bar
        bar.draw(value=i)
927193
function getOverallBarChart(){
    var contextMenuActions = [{
        name: 'Explore windmill', 
        action: function(ae, splitBy, timestamp) {
            explore(splitBy);
        }        
    }]    
    var endDate = new Date(Math.floor((new Date()).valueOf()/(1000*60*60*24))*(1000*60*60*24));
    var startDate = new Date(endDate.valueOf() - 1000*60*60*24*7);
    var aggregateExpressions = [];
    aggregateExpressions.push(new tsiClient.ux.AggregateExpression({predicateString: "DSCR HAS 'Grid Power'"}, {property: 'VALUE', type: "Double"}, ['sum'],
        { from: startDate, to: endDate, bucketSize: '1d' }, {property: 'UNIT', type: 'String'}, 'teal', 'GridPower', contextMenuActions));
    authContext.getTsiToken().then(function(token){
        tsiClient.server.getAggregates(token, environmentFqdn, aggregateExpressions.map(function(ae){return ae.toTsx()})).then(function(result){
            var barChart = new tsiClient.ux.BarChart(document.getElementById('chart0'));
            var transformedResult = tsiClient.ux.transformAggregatesForVisualization(result, aggregateExpressions);
            barChart.render(transformedResult, {legend: 'hidden', zeroYAxis: true, keepSplitByColor: true, tooltip: true}, aggregateExpressions);
        });    
    });
}
1259715
def bar_chart_mf(data, path_name):
    """"""
    N = len(data)

    ind = np.arange(N)  # the x locations for the groups
    width = 0.8       # the width of the bars

    fig, ax = pyplot.subplots()
    rects1 = ax.bar(ind, data, width, color='g')

    # add some text for labels, title and axes ticks
    ax.set_ylabel('Population')
    ax.set_xticks(ind+width/2)
    labs = ['m='+str(i) for i in range(-N/2+1, N/2+1)]
    ax.set_xticklabels(labs)

    def autolabel(rects):
        # attach some text labels
        for rect in rects:
            rect.get_height()

    autolabel(rects1)
    pyplot.savefig(path_name)
    pyplot.close()
634548
def render(self,
               data,
               chart_type,
               chart_package='corechart',
               options=None,
               div_id="chart",
               head=""):
        """"""
        if not self.is_valid_name(div_id):
            raise ValueError(
                "Name {} is invalid. Only letters, numbers, '_', and '-' are permitted ".format(
                    div_id))

        return Template(head + self.template).render(
            div_id=div_id.replace(" ", "_"),
            data=json.dumps(
                data, indent=4).replace("'", "\\'").replace('"', "'"),
            chart_type=chart_type,
            chart_package=chart_package,
            options=json.dumps(
                options, indent=4).replace("'", "\\'").replace('"', "'"))
458986
function () {
		var chart = this.chart,
			options = this.options,
			offsetLeft = options.offsetLeft || 0,
			offsetRight = options.offsetRight || 0,
			horiz = this.horiz,
			width,
			height,
			top,
			left;

		// Expose basic values to use in Series object and navigator
		this.left = left = pick(options.left, chart.plotLeft + offsetLeft);
		this.top = top = pick(options.top, chart.plotTop);
		this.width = width = pick(options.width, chart.plotWidth - offsetLeft + offsetRight);
		this.height = height = pick(options.height, chart.plotHeight);
		this.bottom = chart.chartHeight - height - top;
		this.right = chart.chartWidth - width - left;

		// Direction agnostic properties
		this.len = mathMax(horiz ? width : height, 0); // mathMax fixes #905
		this.pos = horiz ? left : top; // distance from SVG origin
	}
22616
function () {
		var tick = this,
			axis = tick.axis,
			options = axis.options,
			chart = axis.chart,
			horiz = axis.horiz,
			categories = axis.categories,
			names = axis.series[0] && axis.series[0].names,
			pos = tick.pos,
			labelOptions = options.labels,
			str,
			tickPositions = axis.tickPositions,
			width = (horiz && categories &&
				!labelOptions.step && !labelOptions.staggerLines &&
				!labelOptions.rotation &&
				chart.plotWidth / tickPositions.length) ||
				(!horiz && (chart.margin[3] || chart.chartWidth * 0.33)), // #1580, #1931
			isFirst = pos === tickPositions[0],
			isLast = pos === tickPositions[tickPositions.length - 1],
			css,
			attr,
			value = categories ?
				pick(categories[pos], names && names[pos], pos) : 
				pos,
			label = tick.label,
			tickPositionInfo = tickPositions.info,
			dateTimeLabelFormat;

		// Set the datetime label format. If a higher rank is set for this position, use that. If not,
		// use the general format.
		if (axis.isDatetimeAxis && tickPositionInfo) {
			dateTimeLabelFormat = options.dateTimeLabelFormats[tickPositionInfo.higherRanks[pos] || tickPositionInfo.unitName];
		}

		// set properties for access in render method
		tick.isFirst = isFirst;
		tick.isLast = isLast;

		// get the string
		str = axis.labelFormatter.call({
			axis: axis,
			chart: chart,
			isFirst: isFirst,
			isLast: isLast,
			dateTimeLabelFormat: dateTimeLabelFormat,
			value: axis.isLog ? correctFloat(lin2log(value)) : value
		});

		// prepare CSS
		css = width && { width: mathMax(1, mathRound(width - 2 * (labelOptions.padding || 10))) + PX };
		css = extend(css, labelOptions.style);

		// first call
		if (!defined(label)) {
			attr = {
				align: axis.labelAlign
			};
			if (isNumber(labelOptions.rotation)) {
				attr.rotation = labelOptions.rotation;
			}
			if (width && labelOptions.ellipsis) {
				attr._clipHeight = axis.len / tickPositions.length;
			}

			tick.label =
				defined(str) && labelOptions.enabled ?
					chart.renderer.text(
							str,
							0,
							0,
							labelOptions.useHTML
						)
						.attr(attr)
						// without position absolute, IE export sometimes is wrong
						.css(css)
						.add(axis.labelGroup) :
					null;

		// update
		} else if (label) {
			label.attr({
					text: str
				})
				.css(css);
		}
	}
302722
function drawItemLabels(legend, barGroup) {
  // draw a subtle tick to help indicate what the label refers to
  function drawTick(y) {
    barGroup.appendChild(
      svgElement(
        legend,
        "line",
        {
          x1: legend.itemWidth,
          x2: legend.itemWidth + 5,
          y1: y,
          y2: y
        },
        "tick-mark"
      )
    );
  }

  function drawLabel(y, text) {
    var textOffsetX = 7;
    var textOffsetY = 3; // pixel shuffling to get the text to line up just right.
    barGroup.appendChild(
      svgElement(
        legend,
        "text",
        {
          x: legend.itemWidth + textOffsetX,
          y: y + textOffsetY
        },
        "item-label" + (legend.items.length > 6 ? "-small" : ""),
        text
      )
    );
  }

  legend.items.forEach(function(item, i) {
    var y = itemY(legend, i);
    if (defined(item.titleAbove)) {
      drawLabel(y, item.titleAbove);
      drawTick(y);
    }
    if (defined(item.title)) {
      drawLabel(y + legend.computedItemHeight / 2, item.title);
    }
    if (defined(item.titleBelow)) {
      drawLabel(y + legend.computedItemHeight, item.titleBelow);
      drawTick(y + legend.computedItemHeight);
    }
  });

  return itemY(legend, -1);
}