/** * Adds a point to this canvas. */ public void point(char legend, Color color, double... coord) { add(new Point(legend, color, coord)); }
/** * Adds a point to this canvas. */ public void point(double... coord) { add(new Point(coord)); }
/** * Adds a point to this canvas. */ public void point(char legend, double... coord) { add(new Point(legend, coord)); }
/** * Adds a 2D grid plot to the canvas. * @param data an m x n x 2 array which are coordinates of m x n grid. */ public Grid grid(double[][][] data) { if (base.dimension != 2) { throw new IllegalArgumentException("Grid can be only painted in a 2D canvas. Try surface() for 3D grid."); } Grid grid = new Grid(data); add(grid); return grid; }
/** * Adds a label to this canvas. */ public void label(String text, double... coord) { add(new Label(text, coord)); }
/** * Adds a point to this canvas. */ public void point(Color color, double... coord) { add(new Point(color, coord)); }
/** * Adds a label to this canvas. */ public void label(String text, Font font, double... coord) { Label label = new Label(text, coord); label.setFont(font); add(label); }
/** * Adds a label to this canvas. */ public void label(String text, Color color, double... coord) { Label label = new Label(text, coord); label.setColor(color); add(label); }
/** * Adds a label to this canvas. */ public void label(String text, Font font, Color color, double... coord) { Label label = new Label(text, coord); label.setFont(font); label.setColor(color); add(label); }
/** * Create a wire frame plot canvas. * @param vertices a n-by-2 or n-by-3 array which are coordinates of n vertices. */ public static PlotCanvas plot(double[][] vertices, int[][] edges) { double[] lowerBound = Math.colMin(vertices); double[] upperBound = Math.colMax(vertices); PlotCanvas canvas = new PlotCanvas(lowerBound, upperBound); Wireframe frame = new Wireframe(vertices, edges); canvas.add(frame); return canvas; }
/** * Create a plot canvas with the 3D surface plot of given data. * @param z the z-axis values of surface. The x-axis and y-axis location of * surface will be set to 0.5, 1.5, 2.5, ... */ public static PlotCanvas plot(double[][] z) { double[] lowerBound = {0, 0, Math.min(z)}; double[] upperBound = {z.length, z[0].length, Math.max(z)}; PlotCanvas canvas = new PlotCanvas(lowerBound, upperBound); Surface surface = new Surface(z); canvas.add(surface); return canvas; }
/** * Create a plot canvas with the contour plot of given data. * @param z a matrix. */ public static PlotCanvas plot(double[] x, double[] y, double[][] z) { double[] lowerBound = {Math.min(x), Math.min(y)}; double[] upperBound = {Math.max(x), Math.max(y)}; PlotCanvas canvas = new PlotCanvas(lowerBound, upperBound, false); canvas.add(new Contour(x, y, z)); return canvas; }
/** * Create a plot canvas with the contour plot of given data. * @param z a matrix. */ public static PlotCanvas plot(double[] x, double[] y, double[][] z, double[] levels, Color[] palette) { double[] lowerBound = {Math.min(x), Math.min(y)}; double[] upperBound = {Math.max(x), Math.max(y)}; PlotCanvas canvas = new PlotCanvas(lowerBound, upperBound, false); canvas.add(new Contour(x, y, z, levels, palette)); return canvas; } }
/** * Create a plot canvas with the contour plot of given data. * @param z a matrix. */ public static PlotCanvas plot(double[][] z, double[] levels, Color[] palette) { double[] lowerBound = {0, 0}; double[] upperBound = {z[0].length, z.length}; PlotCanvas canvas = new PlotCanvas(lowerBound, upperBound, false); canvas.add(new Contour(z, levels, palette)); canvas.getAxis(0).setLabelVisible(false); canvas.getAxis(1).setLabelVisible(false); return canvas; }
/** * Create a plot canvas with the contour plot of given data. * @param z a matrix. */ public static PlotCanvas plot(double[][] z) { double[] lowerBound = {0, 0}; double[] upperBound = {z[0].length, z.length}; PlotCanvas canvas = new PlotCanvas(lowerBound, upperBound, false); canvas.add(new Contour(z)); canvas.getAxis(0).setLabelVisible(false); canvas.getAxis(1).setLabelVisible(false); return canvas; }
/** * Create a plot canvas with the two sample Q-Q plot. * The x-axis is the quantiles of x and the y-axis is the quantiles of y. * @param x a sample set. * @param y a sample set. */ public static PlotCanvas plot(double[] x, double[] y) { double[] lowerBound = {Math.min(x), Math.min(y)}; double[] upperBound = {Math.max(x), Math.max(y)}; PlotCanvas canvas = new PlotCanvas(lowerBound, upperBound); canvas.add(new QQPlot(x, y)); return canvas; }
/** * Create a plot canvas with the one sample Q-Q plot to given distribution. * The x-axis is the quantiles of x and the y-axis is the quantiles of * given distribution. * @param x a sample set. * @param d a distribution. */ public static PlotCanvas plot(double[] x, Distribution d) { double[] lowerBound = {Math.min(x), d.quantile(1 / (x.length + 1.0))}; double[] upperBound = {Math.max(x), d.quantile(x.length / (x.length + 1.0))}; PlotCanvas canvas = new PlotCanvas(lowerBound, upperBound); canvas.add(new QQPlot(x, d)); return canvas; }
/** * Create a plot canvas with the box plot of given data. * @param data a sample set. */ public static PlotCanvas plot(double[] data) { double[] lowerBound = {0, Math.min(data)}; double[] upperBound = {1, Math.max(data)}; PlotCanvas canvas = new PlotCanvas(lowerBound, upperBound); canvas.add(new BoxPlot(data)); canvas.getAxis(0).setGridVisible(false); canvas.getAxis(0).setLabelVisible(false); return canvas; }
/** * Create a plot canvas with the one sample Q-Q plot to standard normal * distribution. The x-axis is the quantiles of x and the y-axis is the * quantiles of normal distribution. * @param x a sample set. */ public static PlotCanvas plot(double[] x) { double[] lowerBound = {Math.min(x), GaussianDistribution.getInstance().quantile(1 / (x.length + 1.0))}; double[] upperBound = {Math.max(x), GaussianDistribution.getInstance().quantile(x.length / (x.length + 1.0))}; PlotCanvas canvas = new PlotCanvas(lowerBound, upperBound); canvas.add(new QQPlot(x)); return canvas; }
/** * Create a plot canvas with multiple box plots of given data. * @param data a data matrix of which each row will create a box plot. */ public static PlotCanvas plot(double[]... data) { double[] lowerBound = {0, Math.min(data)}; double[] upperBound = {data.length, Math.max(data)}; PlotCanvas canvas = new PlotCanvas(lowerBound, upperBound); canvas.add(new BoxPlot(data)); canvas.getAxis(0).setGridVisible(false); canvas.getAxis(0).setLabelVisible(false); return canvas; }