Adds a histogram to this canvas.
@param data a sample set.
@param k the number of bins.
767383
public Histogram histogram(double[] data, int k, Color color) {
        return histogram(null, data, k, color);
    }
451692
public void addHistogram(String histogramID, String xAxisLabel, String yAxisLabel) throws ShanksException {
        if (!this.histograms.containsKey(histogramID)) {
            HistogramGenerator histogram = new HistogramGenerator();
            histogram.setTitle(histogramID);
            histogram.setXAxisLabel(xAxisLabel);
            histogram.setYAxisLabel(yAxisLabel);
            this.histograms.put(histogramID, histogram);
        } else {
            throw new DuplicatedChartIDException(histogramID);
        }
    }
1256284
public static void saveHistogram(Histogram histogram, String filename) throws IOException {
    File file;
    PrintStream log = null;
    try {
      file = new File(filename);
      if (file.exists() && !file.delete()) {
        System.err.println("Failed deleting previous histogram file: " + file.getAbsolutePath());
      }
      log = new PrintStream(new FileOutputStream(file), false);
      histogram.outputPercentileDistribution(log, 1.0);
    } finally {
      if (log != null) {
        log.close();
      }
    }
  }
1134728
private void init(double[][] data, int xbins, int ybins, boolean prob) {
        // Generate the histogram.
        if (data.length == 0) {
            throw new IllegalArgumentException("array is empty.");
        }

        if (data[0].length != 2) {
            throw new IllegalArgumentException("dimension is not 2.");
        }

        double xmin = data[0][0];
        double xmax = data[0][0];
        double ymin = data[0][1];
        double ymax = data[0][1];
        for (int i = 1; i < data.length; i++) {
            if (xmin > data[i][0]) {
                xmin = data[i][0];
            }
            if (xmax < data[i][0]) {
                xmax = data[i][0];
            }

            if (ymin > data[i][1]) {
                ymin = data[i][1];
            }
            if (ymax < data[i][1]) {
                ymax = data[i][1];
            }
        }

        double xspan = xmax - xmin;
        double xwidth = xspan / xbins;
        double yspan = ymax - ymin;
        double ywidth = yspan / ybins;

        freq = new double[xbins * ybins][3];
        freq[0][0] = xmin + xwidth / 2;
        freq[0][1] = ymin + ywidth / 2;
        for (int i = 0; i < xbins; i++) {
            for (int j = 0; j < ybins; j++) {
                freq[j * xbins + i][0] = freq[0][0] + xwidth * i;
                freq[j * xbins + i][1] = freq[0][1] + ywidth * j;
            }
        }

        for (int k = 0; k < data.length; k++) {
            int i = (int) ((data[k][0] - xmin) / xwidth);
            if (i >= xbins) {
                i = xbins - 1;
            }

            int j = (int) ((data[k][1] - ymin) / ywidth);
            if (j >= ybins) {
                j = ybins - 1;
            }

            freq[j * xbins + i][2]++;
        }

        if (prob) {
            for (int i = 0; i < freq.length; i++) {
                freq[i][2] /= data.length;
            }
        }

        max = Double.NEGATIVE_INFINITY;
        for (int i = 0; i < freq.length; i++) {
            if (freq[i][2] > max) {
                max = freq[i][2];
            }
        }
        
        if (palette != null) {
            width = max / palette.length;
        }

        // calculate cube coordinates.
        topNW = new double[freq.length][3];
        topNE = new double[freq.length][3];
        topSW = new double[freq.length][3];
        topSE = new double[freq.length][3];
        bottomNW = new double[freq.length][3];
        bottomNE = new double[freq.length][3];
        bottomSW = new double[freq.length][3];
        bottomSE = new double[freq.length][3];
        for (int i = 0; i < freq.length; i++) {
            topNW[i][0] = freq[i][0] - xwidth / 2;
            topNW[i][1] = freq[i][1] + ywidth / 2;
            topNW[i][2] = freq[i][2];

            topNE[i][0] = freq[i][0] + xwidth / 2;
            topNE[i][1] = freq[i][1] + ywidth / 2;
            topNE[i][2] = freq[i][2];

            topSW[i][0] = freq[i][0] - xwidth / 2;
            topSW[i][1] = freq[i][1] - ywidth / 2;
            topSW[i][2] = freq[i][2];

            topSE[i][0] = freq[i][0] + xwidth / 2;
            topSE[i][1] = freq[i][1] - ywidth / 2;
            topSE[i][2] = freq[i][2];

            bottomNW[i][0] = freq[i][0] - xwidth / 2;
            bottomNW[i][1] = freq[i][1] + ywidth / 2;
            bottomNW[i][2] = 0;

            bottomNE[i][0] = freq[i][0] + xwidth / 2;
            bottomNE[i][1] = freq[i][1] + ywidth / 2;
            bottomNE[i][2] = 0;

            bottomSW[i][0] = freq[i][0] - xwidth / 2;
            bottomSW[i][1] = freq[i][1] - ywidth / 2;
            bottomSW[i][2] = 0;

            bottomSE[i][0] = freq[i][0] + xwidth / 2;
            bottomSE[i][1] = freq[i][1] - ywidth / 2;
            bottomSE[i][2] = 0;
        }

        z = new double[6 * freq.length];
        order = new int[6 * freq.length];
        zTopNW = new double[freq.length];
        zTopNE = new double[freq.length];
        zTopSW = new double[freq.length];
        zTopSE = new double[freq.length];
        zBottomNW = new double[freq.length];
        zBottomNE = new double[freq.length];
        zBottomSW = new double[freq.length];
        zBottomSE = new double[freq.length];
    }
915023
void addFlakes(int quantity) {
        for (int i = 0; i < quantity; ++i) {
            flakes.add(Flake.createFlake(getWidth(), droid));
        }
        setNumFlakes(numFlakes + quantity);
    }
149305
def draw(self, y, **kwargs):
        

        # draw the histogram
        hist, bin_edges = np.histogram(y, bins=self.bins)
        self.bin_edges_ = bin_edges
        self.ax.hist(y, bins=self.bins, color=kwargs.pop("color", "#6897bb"), **kwargs)

        # add vetical line with binning reference values
        plt.vlines(bin_edges,0,max(hist),colors=kwargs.pop("colors", "r"))
1092292
public void addSample(double[] sampleData) {
		if (sampleIndex >= numSamples)
			throw new IllegalArgumentException("Too many samples");
		if (sampleData.length != sampleSize)
			throw new IllegalArgumentException("Unexpected sample size");

		for (int i = 0; i < sampleData.length; i++) {
			A.set(sampleIndex, i, sampleData[i]);
		}
		sampleIndex++;
	}
562692
public static void histogram( GrayF32 input , float minValue , int histogram[] ) {
		if( BoofConcurrency.USE_CONCURRENT ) {
			ImplImageStatistics_MT.histogram(input,minValue,histogram);
		} else {
			ImplImageStatistics.histogram(input,minValue,histogram);
		}
	}
1135406
public void add(double centroid, int count, List<Double> data) {
        this.centroid = centroid;
        this.count = count;
        this.data = data;
        tree.add();
    }
45155
public void addAll(Iterable<? extends Datum<L,F>> data) {
    for (Datum<L, F> d : data) {
      add(d);
    }
  }
596283
public static void histogram( GrayS8 input , int minValue , int histogram[] ) {
		if( BoofConcurrency.USE_CONCURRENT ) {
			ImplImageStatistics_MT.histogram(input,minValue,histogram);
		} else {
			ImplImageStatistics.histogram(input,minValue,histogram);
		}
	}
140675
public void addPush(long k) {
        int ik = (int) k;
        if (ik == k) {
            addPush(ik);
            add(ByteCode.I2L);
        } else {
            addLoadConstant(k);
        }
    }
1252478
protected void sortPixels(GrayU8 input) {
		// initialize histogram
		for( int i = 0; i < histogram.length; i++ ) {
			histogram[i].reset();
		}
		// sort by creating a histogram
		for( int y = 0; y < input.height; y++ ) {
			int index = input.startIndex + y*input.stride;
			int indexOut = (y+1)*output.stride + 1;
			for (int x = 0; x < input.width; x++ , index++ , indexOut++) {
				int value = input.data[index] & 0xFF;
				histogram[value].add(indexOut);
			}
		}
	}
1286596
private void addShape(String data)
	{
		if (faces.size() != 0)
		{
			Shape s = new Shape(faces);
			shapes.put(currentShape.toLowerCase(), s);
			faces.clear();
		}

		if (data != "")
			currentShape = data.indexOf('_') != -1 ? data.substring(0, data.indexOf('_')) : data;
	}
467086
public static PlotCanvas plot(String id, double[] data) {
        double[] lowerBound = {0, Math.min(data)};
        double[] upperBound = {data.length, Math.max(data)};
        PlotCanvas canvas = new PlotCanvas(lowerBound, upperBound);

        BarPlot plot = new BarPlot(data);
        plot.setID(id);
        canvas.add(plot);

        canvas.getAxis(0).setGridVisible(false);
        canvas.getAxis(0).setLabelVisible(false);

        return canvas;
    }
1126383
@Override
  public void add(Object data, Class<?>... typeSpecs) {
    //    if (data == null) return;
    //
    //    typeSpecs = determineTypeSpecs(data, typeSpecs);
    //    if (this.getDefaultDataType() == null) this.setDefaultDataType(typeSpecs);
    //
    //    mReps.put(this.getSpecsAsString(typeSpecs), data);
    Representation representation = new Representation(data, typeSpecs);
    mReps.put(representation.getTypeSpecsString(), representation);
  }
1273815
@Override void add0( DRealHistogram dsh ) {
    Utils.add(_sums,dsh._sums);
    Utils.add(_ssqs,dsh._ssqs);
  }