Draw bar graph.
 Now handles positive and negative values gracefully.
6523
def draw(svg, coords, options = {})
      coords.each_with_index do |coord,idx|
        next if coord.nil?
        x, y, bar_height = (coord.first), coord.last, 1#(height - coord.last)
        
          valh = max_value + min_value * -1 #value_height
          maxh = max_value * height / valh #positive area height
          minh = min_value * height / valh #negative area height
          #puts "height = #{height} and max_value = #{max_value} and min_value = #{min_value} and y = #{y} and point = #{points[idx]}"
          if points[idx] > 0
            bar_height = points[idx]*maxh/max_value
          else
            bar_height = points[idx]*minh/min_value
          end
        
        #puts " y = #{y} and point = #{points[idx]}"  
        unless options[:border] == false
          svg.g(:transform => "translate(-#{relative(0.5)}, -#{relative(0.5)})") {
            svg.rect( :x => x, :y => y, :width => @bar_width + relative(1), :height => bar_height + relative(1), 
                      :style => "fill: black; fill-opacity: 0.15; stroke: none;" )
            svg.rect( :x => x+relative(0.5), :y => y+relative(2), :width => @bar_width + relative(1), :height => bar_height - relative(0.5), 
                      :style => "fill: black; fill-opacity: 0.15; stroke: none;" )
          }
        end
        
        current_colour = color.is_a?(Array) ? color[idx % color.size] : color
        
        svg.rect( :x => x, :y => y, :width => @bar_width, :height => bar_height, 
          :fill => current_colour.to_s, 'style' => "opacity: #{opacity}; stroke: none;" )
      end
    end
813280
def plot(self, x, y, color="black"):
        
        p = Point(x, y)
        p.fill(color)
        p.draw(self)
1227340
def _bar(self, serie, parent, x, y, i, zero, secondary=False):
        """"""
        if secondary:
            cumulation = (
                self.secondary_negative_cumulation
                if y < self.zero else self.secondary_positive_cumulation
            )
        else:
            cumulation = (
                self.negative_cumulation
                if y < self.zero else self.positive_cumulation
            )
        zero = cumulation[i]
        cumulation[i] = zero + y
        if zero == 0:
            zero = self.zero
            y -= self.zero
        y += zero

        width = (self.view.x(1) - self.view.x(0)) / self._len
        x, y = self.view((x, y))
        y = y or 0
        series_margin = width * self._series_margin
        x += series_margin
        width -= 2 * series_margin
        if self.secondary_series:
            width /= 2
            x += int(secondary) * width
            serie_margin = width * self._serie_margin
            x += serie_margin
            width -= 2 * serie_margin
        height = self.view.y(zero) - y
        r = serie.rounded_bars * 1 if serie.rounded_bars else 0
        self.svg.transposable_node(
            parent,
            'rect',
            x=x,
            y=y,
            rx=r,
            ry=r,
            width=width,
            height=height,
            class_='rect reactive tooltip-trigger'
        )
        return x, y, width, height
513236
protected void drawBars(Canvas _Canvas) {

        RectF  bounds;
        String valueString;
        float  animatedRightOffset;

        for (BarModel model : mData) {
            bounds              = model.getBarBounds();
            valueString         = Utils.getFloatString(model.getValue(), mShowDecimal) + mValueUnit;
            animatedRightOffset = bounds.right * mRevealValue;

            mGraphPaint.setColor(model.getColor());

            _Canvas.drawRect(
                    bounds.left,
                    bounds.top,
                    bounds.right * mRevealValue,
                    bounds.bottom, mGraphPaint);

            if (mShowValues && animatedRightOffset > mValuePaint.measureText(valueString)) {
                mValuePaint.setColor(mLegendColor);
                _Canvas.drawText(
                        valueString,
                        bounds.left + mValueDistance,
                        bounds.centerY() + (mMaxFontHeight / 2),
                        mValuePaint
                );
            }

            if (mShowBarLabel) {
                mValuePaint.setColor(mBarLabelColor);
                _Canvas.drawText(
                        model.getLegendLabel(),
                        animatedRightOffset + mValueDistance,
                        bounds.centerY() + (mMaxFontHeight / 2),
                        mValuePaint
                );
            }
        }
    }
2698
def draw(self):
        
        if self.iso_f1_curves:
            for f1 in self.iso_f1_values:
                x = np.linspace(0.01, 1)
                y = f1 * x / (2 * x - f1)
                self.ax.plot(x[y>=0], y[y>=0], color='#333333', alpha=0.2)
                self.ax.annotate('$f_1={:0.1f}$'.format(f1), xy=(0.9, y[45]+0.02))

        if self.target_type_ == BINARY:
            return self._draw_binary()
        return self._draw_multiclass()
222000
def _bar(s, align, colors, width=100, vmin=None, vmax=None):
        
        # Get input value range.
        smin = s.min() if vmin is None else vmin
        if isinstance(smin, ABCSeries):
            smin = smin.min()
        smax = s.max() if vmax is None else vmax
        if isinstance(smax, ABCSeries):
            smax = smax.max()
        if align == 'mid':
            smin = min(0, smin)
            smax = max(0, smax)
        elif align == 'zero':
            # For "zero" mode, we want the range to be symmetrical around zero.
            smax = max(abs(smin), abs(smax))
            smin = -smax
        # Transform to percent-range of linear-gradient
        normed = width * (s.values - smin) / (smax - smin + 1e-12)
        zero = -width * smin / (smax - smin + 1e-12)

        def css_bar(start, end, color):
            """
            Generate CSS code to draw a bar from start to end.
            """
            css = 'width: 10em; height: 80%;'
            if end > start:
                css += 'background: linear-gradient(90deg,'
                if start > 0:
                    css += ' transparent {s:.1f}%, {c} {s:.1f}%, '.format(
                        s=start, c=color
                    )
                css += '{c} {e:.1f}%, transparent {e:.1f}%)'.format(
                    e=min(end, width), c=color,
                )
            return css

        def css(x):
            if pd.isna(x):
                return ''

            # avoid deprecated indexing `colors[x > zero]`
            color = colors[1] if x > zero else colors[0]

            if align == 'left':
                return css_bar(0, x, color)
            else:
                return css_bar(min(x, zero), max(x, zero), color)

        if s.ndim == 1:
            return [css(x) for x in normed]
        else:
            return pd.DataFrame(
                [[css(x) for x in row] for row in normed],
                index=s.index, columns=s.columns
            )
1347561
def draw(self,N=1.5):
        
        while N>0.5:
            for (l,mvmt) in self.ordering_step():
                pass
            N = N-1
        if N>0:
            for (l,mvmt) in self.ordering_step(oneway=True):
                pass
        self.setxy()
        self.draw_edges()
151735
function drawChart(chart) {
	var streaming = chart.streaming;
	var frameRate = chart.options.plugins.streaming.frameRate;
	var frameDuration = 1000 / (Math.max(frameRate, 0) || 30);
	var next = streaming.lastDrawn + frameDuration || 0;
	var now = Date.now();
	var lastMouseEvent = streaming.lastMouseEvent;

	if (next <= now) {
		// Draw only when animation is inactive
		if (!chart.animating && !chart.tooltip._start) {
			chart.draw();
		}
		if (lastMouseEvent) {
			chart.eventHandler(lastMouseEvent);
		}
		streaming.lastDrawn = (next + frameDuration > now) ? next : now;
	}
}
71494
def draw(self):
        
        # Number of colors is either number of classes or 2
        colors = resolve_colors(len(self.support_))

        if self._mode == BALANCE:
            self.ax.bar(
                np.arange(len(self.support_)), self.support_,
                color=colors, align='center', width=0.5
            )

        # Compare mode
        else:
            bar_width = 0.35
            labels = ["train", "test"]

            for idx, support in enumerate(self.support_):
                index = np.arange(len(self.classes_))
                if idx > 0:
                    index = index + bar_width

                self.ax.bar(
                    index, support, bar_width,
                    color=colors[idx], label=labels[idx]
                )

        return self.ax
897707
function () {
		var options = this.options,
			chart = this.chart,
			renderer = chart.renderer,
			negativeColor = options.negativeColor || options.negativeFillColor,
			translatedThreshold,
			posAttr,
			negAttr,
			graph = this.graph,
			area = this.area,
			posClip = this.posClip,
			negClip = this.negClip,
			chartWidth = chart.chartWidth,
			chartHeight = chart.chartHeight,
			chartSizeMax = mathMax(chartWidth, chartHeight),
			yAxis = this.yAxis,
			above,
			below;
		
		if (negativeColor && (graph || area)) {
			translatedThreshold = mathRound(yAxis.toPixels(options.threshold || 0, true));
			above = {
				x: 0,
				y: 0,
				width: chartSizeMax,
				height: translatedThreshold
			};
			below = {
				x: 0,
				y: translatedThreshold,
				width: chartSizeMax,
				height: chartSizeMax
			};
			
			if (chart.inverted) {

				above.height = below.y = chart.plotWidth - translatedThreshold;
				if (renderer.isVML) {
					above = {
						x: chart.plotWidth - translatedThreshold - chart.plotLeft,
						y: 0,
						width: chartWidth,
						height: chartHeight
					};
					below = {
						x: translatedThreshold + chart.plotLeft - chartWidth,
						y: 0,
						width: chart.plotLeft + translatedThreshold,
						height: chartWidth
					};
				}
			}
			
			if (yAxis.reversed) {
				posAttr = below;
				negAttr = above;
			} else {
				posAttr = above;
				negAttr = below;
			}
		
			if (posClip) { // update
				posClip.animate(posAttr);
				negClip.animate(negAttr);
			} else {
				
				this.posClip = posClip = renderer.clipRect(posAttr);
				this.negClip = negClip = renderer.clipRect(negAttr);
				
				if (graph && this.graphNeg) {
					graph.clip(posClip);
					this.graphNeg.clip(negClip);	
				}
				
				if (area) {
					area.clip(posClip);
					this.areaNeg.clip(negClip);
				} 
			} 
		}	
	}
700105
def draw(self):
        
        # Set the colors from the supplied values or reasonable defaults
        color_values = resolve_colors(n_colors=4, colors=self.color)

        for idx, metric in enumerate(METRICS):
            # Skip any excluded labels
            if metric not in self.cv_scores_:
                continue

            # Get the color ensuring every metric has a static color
            color = color_values[idx]

            # Make the label pretty
            if metric == "fscore":
                if self.fbeta == 1.0:
                    label = "$f_1$"
                else:
                    label = "$f_{{\beta={:0.1f}}}".format(self.fbeta)
            else:
                label = metric.replace("_", " ")

            # Draw the metric values
            self.ax.plot(
                self.thresholds_, self.cv_scores_[metric],
                color=color, label=label
            )

            # Draw the upper and lower bounds
            lower = self.cv_scores_["{}_lower".format(metric)]
            upper = self.cv_scores_["{}_upper".format(metric)]

            self.ax.fill_between(
                self.thresholds_, upper, lower,
                alpha=0.35, linewidth=0, color=color
            )

            # Annotate the graph with the maximizing value
            if self.argmax.lower() == metric:
                argmax = self.cv_scores_[metric].argmax()
                threshold = self.thresholds_[argmax]
                self.ax.axvline(
                    threshold, ls='--', c='k', lw=1,
                    label="$t_{}={:0.2f}$".format(metric[0], threshold)
                )

        return self.ax
108369
def draw(self):
        
        pos = np.arange(self.scores_.shape[0]) + 0.5

        self.ax.barh(pos, self.scores_)

        # Set the labels for the bars
        self.ax.set_yticks(pos)
        self.ax.set_yticklabels(self.features_)

        return self.ax
512917
def draw(self, X, y, **kwargs):
        
        nan_col_counts = self.get_nan_col_counts()

        # the x locations for the groups
        self.ind = np.arange(len(self.features_))

        if y is None:
            self.ax.barh(self.ind - self.width / 2, nan_col_counts, self.width,
                            color=self.color, label=None)
        else:
            self.draw_stacked_bar(nan_col_counts)
663835
def draw(args):
    """"""
    if len(args) != 2:
        log.error('Two arguments required: [build target] [output file]')
        app.quit(1)

    target = args[0]
    out = args[1]

    try:
        bb = Butcher()
        bb.load_graph(target)
    except error.BrokenGraph as lolno:
        log.fatal(lolno)
        app.quit(1)

    # Filter down to the target and all of its transitive dependencies.
    # TODO: make it possible to optionally draw the entire graph
    filtered_graph = bb.graph.subgraph(
        networkx.topological_sort(bb.graph, nbunch=[address.new(target)]))

    a = networkx.to_agraph(filtered_graph)
    a.draw(out, prog='dot')
    log.info('Graph written to %s', out)
681603
def draw_progress_bar(cb, message, value, max_value):
    
    m_x = cb.width // 2
    m_y = cb.height // 2
    w = len(message) + 4
    h = 3
    draw_box(cb, m_x - w // 2, m_y - 1, w, h)
    message = " %s " % message
    i = int((value / max_value) * (len(message) + 2))
    message = "$" + message[:i] + "$" + message[i:]
    draw_text(cb, m_x - w // 2 + 1, m_y, message)
281053
@Override
    protected void onGraphDraw(Canvas _Canvas) {
        super.onGraphDraw(_Canvas);
        _Canvas.translate(-mCurrentViewport.left, -mCurrentViewport.top);
        drawBars(_Canvas);
    }
1090314
def setgraphval(delta, graph, key, val):
    """"""
    delta.setdefault(graph, {})[key] = val