/** * Adds a scatter plot to this canvas. * @param id the id of the plot. * @param data a n-by-2 or n-by-3 matrix that describes coordinates of points. * @param labels labels of points. * @return the scatter plot for the given points. */ public ScatterPlot points(String id, double[][] data, String[] labels) { if (data[0].length != base.dimension) { throw new IllegalArgumentException("Invalid data dimension: " + data[0].length); } if (data.length != labels.length) { throw new IllegalArgumentException("The number of points and that of labels are not same."); } double[] lowerBound = Math.colMin(data); double[] upperBound = Math.colMax(data); extendBound(lowerBound, upperBound); ScatterPlot plot = new ScatterPlot(data, labels); plot.setID(id); add(plot); return plot; }
/** * Adds a poly line plot to this canvas. * @param id the id of the plot. * @param data a n-by-2 or n-by-3 matrix that describes coordinates of points. */ public LinePlot line(String id, double[]... data) { if (data[0].length != base.dimension) { throw new IllegalArgumentException("Invalid data dimension: " + data[0].length); } double[] lowerBound = Math.colMin(data); double[] upperBound = Math.colMax(data); extendBound(lowerBound, upperBound); LinePlot plot = new LinePlot(data); plot.setID(id); add(plot); return plot; }
/** * Adds a scatter plot to this canvas. * @param id the id of the plot. * @param data a n-by-2 or n-by-3 matrix that describes coordinates of points. * @return the scatter plot for the given points. */ public ScatterPlot points(String id, double[]... data) { if (data[0].length != base.dimension) { throw new IllegalArgumentException("Invalid data dimension: " + data[0].length); } double[] lowerBound = Math.colMin(data); double[] upperBound = Math.colMax(data); extendBound(lowerBound, upperBound); ScatterPlot plot = new ScatterPlot(data); plot.setID(id); add(plot); return plot; }
/** * Adds a poly line plot to this canvas. * @param id the id of the plot. * @param data a n-by-2 or n-by-3 matrix that describes coordinates of points. * @param style the stroke style of line. */ public LinePlot line(String id, double[][] data, Line.Style style) { if (data[0].length != base.dimension) { throw new IllegalArgumentException("Invalid data dimension: " + data[0].length); } double[] lowerBound = Math.colMin(data); double[] upperBound = Math.colMax(data); extendBound(lowerBound, upperBound); LinePlot plot = new LinePlot(data, style); plot.setID(id); add(plot); return plot; }
/** * Adds a poly line plot to this canvas. * @param id the id of the plot. * @param data a n-by-2 or n-by-3 matrix that describes coordinates of points. * @param color the color of line. */ public LinePlot line(String id, double[][] data, Color color) { if (data[0].length != base.dimension) { throw new IllegalArgumentException("Invalid data dimension: " + data[0].length); } double[] lowerBound = Math.colMin(data); double[] upperBound = Math.colMax(data); extendBound(lowerBound, upperBound); LinePlot plot = new LinePlot(data); plot.setID(id); plot.setColor(color); add(plot); return plot; }
/** * Adds a poly line plot to this canvas. * @param id the id of the plot. * @param data a n x 2 or n x 3 matrix that describes coordinates of points. * @param style the stroke style of line. * @param color the color of line. */ public LinePlot line(String id, double[][] data, Line.Style style, Color color) { if (data[0].length != base.dimension) { throw new IllegalArgumentException("Invalid data dimension: " + data[0].length); } double[] lowerBound = Math.colMin(data); double[] upperBound = Math.colMax(data); extendBound(lowerBound, upperBound); LinePlot plot = new LinePlot(data, style); plot.setID(id); plot.setColor(color); add(plot); return plot; }
/** * Adds a scatter plot to this canvas. * @param id the id of the plot. * @param data a n-by-2 or n-by-3 matrix that describes coordinates of points. * @param color the color used to draw points. * @return the scatter plot for the given points. */ public ScatterPlot points(String id, double[][] data, Color color) { if (data[0].length != base.dimension) { throw new IllegalArgumentException("Invalid data dimension: " + data[0].length); } double[] lowerBound = Math.colMin(data); double[] upperBound = Math.colMax(data); extendBound(lowerBound, upperBound); ScatterPlot plot = new ScatterPlot(data); plot.setID(id); plot.setColor(color); add(plot); return plot; }
extendBound(lowerBound, upperBound);
/** * Adds a poly line plot to this canvas. * @param id the id of the plot. * @param y a data vector that describes y coordinates of points. The x * coordinates will be [0, n), where n is the length of y. */ public LinePlot line(String id, double[] y) { double[] lowerBound = {0, Math.min(y)}; double[] upperBound = {y.length, Math.max(y)}; extendBound(lowerBound, upperBound); double[][] data = new double[y.length][2]; for (int i = 0; i < data.length; i++) { data[i][0] = i; data[i][1] = y[i]; } LinePlot plot = new LinePlot(data); plot.setID(id); add(plot); return plot; }
/** * Adds a poly line plot to this canvas. * @param id the id of the plot. * @param y a data vector that describes y coordinates of points. The x * coordinates will be [0, n), where n is the length of y. * @param style the stroke style of line. */ public LinePlot line(String id, double[] y, Line.Style style) { double[] lowerBound = {0, Math.min(y)}; double[] upperBound = {y.length, Math.max(y)}; extendBound(lowerBound, upperBound); double[][] data = new double[y.length][2]; for (int i = 0; i < data.length; i++) { data[i][0] = i; data[i][1] = y[i]; } LinePlot plot = new LinePlot(data, style); plot.setID(id); add(plot); return plot; }
/** * 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. */ 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. * @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 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, 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; }
extendBound(lowerBound, upperBound);
/** * 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 poly line plot to this canvas. * @param id the id of the plot. * @param y a data vector that describes y coordinates of points. The x * coordinates will be [0, n), where n is the length of y. * @param color the color of line. */ public LinePlot line(String id, double[] y, Color color) { double[] lowerBound = {0, Math.min(y)}; double[] upperBound = {y.length, Math.max(y)}; extendBound(lowerBound, upperBound); double[][] data = new double[y.length][2]; for (int i = 0; i < data.length; i++) { data[i][0] = i; data[i][1] = y[i]; } LinePlot plot = new LinePlot(data); plot.setID(id); plot.setColor(color); add(plot); return plot; }
/** * Add a poly line plot of given data into the current canvas. * @param id the id of the plot. * @param y a data vector that describes y coordinates of points. The x * coordinates will be [0, n), where n is the length of y. * @param style the stroke style of line. * @param color the color of line. */ public LinePlot line(String id, double[] y, Line.Style style, Color color) { double[] lowerBound = {0, Math.min(y)}; double[] upperBound = {y.length, Math.max(y)}; extendBound(lowerBound, upperBound); double[][] data = new double[y.length][2]; for (int i = 0; i < data.length; i++) { data[i][0] = i; data[i][1] = y[i]; } LinePlot plot = new LinePlot(data, style); plot.setID(id); plot.setColor(color); add(plot); return plot; }