/** * Adds a histogram to this canvas. * @param id the id of the plot. * @param data a sample set. */ public Histogram histogram(String id, double[] data, Color color) { if (base.dimension != 2) { throw new IllegalArgumentException("Histogram can be only painted in a 2D canvas."); } Histogram histogram = new Histogram(data); histogram.setID(id); histogram.setColor(color); double[] lowerBound = {Math.min(data), 0}; double[] upperBound = {Math.max(data), 0}; double[][] freq = histogram.getHistogram(); for (int i = 0; i < freq.length; i++) { if (freq[i][1] > upperBound[1]) { upperBound[1] = freq[i][1]; } } extendBound(lowerBound, upperBound); add(histogram); return histogram; }
/** * Adds a histogram to this canvas. * @param id the id of the plot. * @param data a sample set. */ public Histogram histogram(String id, int[] data, Color color) { if (base.dimension != 2) { throw new IllegalArgumentException("Histogram can be only painted in a 2D canvas."); } Histogram histogram = new Histogram(data); histogram.setID(id); histogram.setColor(color); double[] lowerBound = {Math.min(data) - 0.5, 0}; double[] upperBound = {Math.max(data) + 0.5, 0}; double[][] freq = histogram.getHistogram(); for (int i = 0; i < freq.length; i++) { if (freq[i][1] > upperBound[1]) { upperBound[1] = freq[i][1]; } } extendBound(lowerBound, upperBound); add(histogram); return histogram; }
/** * Adds a histogram to this canvas. * @param id the id of the plot. * @param data a sample set. * @param k the number of bins. */ public Histogram histogram(String id, int[] data, int k, Color color) { if (base.dimension != 2) { throw new IllegalArgumentException("Histogram can be only painted in a 2D canvas."); } Histogram histogram = new Histogram(data, k); histogram.setID(id); histogram.setColor(color); double[] lowerBound = {Math.min(data) - 0.5, 0}; double[] upperBound = {Math.max(data) + 0.5, 0}; double[][] freq = histogram.getHistogram(); for (int i = 0; i < freq.length; i++) { if (freq[i][1] > upperBound[1]) { upperBound[1] = freq[i][1]; } } extendBound(lowerBound, upperBound); add(histogram); return histogram; }
/** * Adds a histogram to this canvas. * @param id the id of the plot. * @param data a sample set. * @param breaks an array of size k+1 giving the breakpoints between * histogram cells. Must be in ascending order. */ public Histogram histogram(String id, int[] data, double[] breaks, Color color) { if (base.dimension != 2) { throw new IllegalArgumentException("Histogram can be only painted in a 2D canvas."); } Histogram histogram = new Histogram(data, breaks); histogram.setID(id); histogram.setColor(color); double[] lowerBound = {Math.min(data) - 0.5, 0}; double[] upperBound = {Math.max(data) + 0.5, 0}; double[][] freq = histogram.getHistogram(); for (int i = 0; i < freq.length; i++) { if (freq[i][1] > upperBound[1]) { upperBound[1] = freq[i][1]; } } extendBound(lowerBound, upperBound); add(histogram); return histogram; }
/** * Adds a histogram to this canvas. * @param id the id of the plot. * @param data a sample set. * @param k the number of bins. */ public Histogram histogram(String id, double[] data, int k, Color color) { if (base.dimension != 2) { throw new IllegalArgumentException("Histogram can be only painted in a 2D canvas."); } Histogram histogram = new Histogram(data, k); histogram.setID(id); histogram.setColor(color); double[] lowerBound = {Math.min(data), 0}; double[] upperBound = {Math.max(data), 0}; double[][] freq = histogram.getHistogram(); for (int i = 0; i < freq.length; i++) { if (freq[i][1] > upperBound[1]) { upperBound[1] = freq[i][1]; } } extendBound(lowerBound, upperBound); add(histogram); return histogram; }
/** * Adds a histogram to this canvas. * @param id the id of the plot. * @param data a sample set. * @param breaks an array of size k+1 giving the breakpoints between * histogram cells. Must be in ascending order. */ public Histogram histogram(String id, double[] data, double[] breaks, Color color) { if (base.dimension != 2) { throw new IllegalArgumentException("Histogram can be only painted in a 2D canvas."); } Histogram histogram = new Histogram(data, breaks); histogram.setID(id); histogram.setColor(color); double[] lowerBound = {Math.min(data), 0}; double[] upperBound = {Math.max(data), 0}; double[][] freq = histogram.getHistogram(); for (int i = 0; i < freq.length; i++) { if (freq[i][1] > upperBound[1]) { upperBound[1] = freq[i][1]; } } extendBound(lowerBound, upperBound); add(histogram); return histogram; }