/** * Set if the frame visible. */ public BaseGrid setFrameVisible(boolean v) { for (int i = 0; i < axis.length; i++) { axis[i].setGridVisible(v); } return this; }
/** * Set if the grid visible. */ public BaseGrid setGridVisible(int i, boolean v) { axis[i].setGridVisible(v); return this; }
/** * Create a plot canvas with the pseudo heat map plot of given data. * @param x x coordinate of data matrix cells. Must be in ascending order. * @param y y coordinate of data matrix cells. Must be in ascending order. * @param z a data matrix to be shown in pseudo heat map. */ 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 Heatmap(x, y, z)); canvas.getAxis(0).setGridVisible(false); canvas.getAxis(1).setGridVisible(false); return canvas; }
/** * Create a plot canvas with the pseudo heat map plot of given data. * @param x x coordinate of data matrix cells. Must be in ascending order. * @param y y coordinate of data matrix cells. Must be in ascending order. * @param z a data matrix to be shown in pseudo heat map. * @param palette the color palette. */ public static PlotCanvas plot(double[] x, double[] y, double[][] z, 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 Heatmap(x, y, z, palette)); canvas.getAxis(0).setGridVisible(false); canvas.getAxis(1).setGridVisible(false); return canvas; }
/** * Create a sparse matrix plot canvas. * @param sparse a sparse matrix. */ public static PlotCanvas plot(SparseMatrix sparse) { double[] lowerBound = {0, 0}; double[] upperBound = {sparse.ncols(), sparse.nrows()}; PlotCanvas canvas = new PlotCanvas(lowerBound, upperBound, false); canvas.add(new SparseMatrixPlot(sparse)); canvas.getAxis(0).setLabelVisible(false); canvas.getAxis(0).setGridVisible(false); canvas.getAxis(1).setLabelVisible(false); canvas.getAxis(1).setGridVisible(false); return canvas; }
/** * Create a sparse matrix plot canvas. * @param sparse a sparse matrix. */ public static PlotCanvas plot(SparseMatrix sparse, Color color) { double[] lowerBound = {0, 0}; double[] upperBound = {sparse.ncols(), sparse.nrows()}; PlotCanvas canvas = new PlotCanvas(lowerBound, upperBound, false); canvas.add(new SparseMatrixPlot(sparse, color)); canvas.getAxis(0).setLabelVisible(false); canvas.getAxis(0).setGridVisible(false); canvas.getAxis(1).setLabelVisible(false); canvas.getAxis(1).setGridVisible(false); return canvas; }
/** * Create a sparse matrix plot canvas. * @param sparse a sparse matrix. */ public static PlotCanvas plot(SparseMatrix sparse, Color[] palette) { double[] lowerBound = {0, 0}; double[] upperBound = {sparse.ncols(), sparse.nrows()}; PlotCanvas canvas = new PlotCanvas(lowerBound, upperBound, false); canvas.add(new SparseMatrixPlot(sparse, palette)); canvas.getAxis(0).setLabelVisible(false); canvas.getAxis(0).setGridVisible(false); canvas.getAxis(1).setLabelVisible(false); canvas.getAxis(1).setGridVisible(false); return canvas; } }
/** * Create a plot canvas with the bar plot of given data. * @param id the id of the plot. * @param data a n x 2 matrix of which data[][0] determine the location of * bars and data[][1] determine the heights of bars. data[][0] will also be * used as the labels. For best view, data[][0] should be monotonic. */ public static PlotCanvas plot(String id, double[]... data) { if (data[0].length != 2) { throw new IllegalArgumentException("Dataset is not 2-dimensional."); } double[] lowerBound = Math.colMin(data); double[] upperBound = Math.colMax(data); PlotCanvas canvas = new PlotCanvas(lowerBound, upperBound); canvas.getAxis(0).setGridVisible(false); BarPlot plot = new BarPlot(data); plot.setID(id); canvas.add(plot); return canvas; } }
/** * Create a plot canvas with the pseudo hexmap plot of given data. * @param data a data matrix to be shown in hexmap. */ public static PlotCanvas plot(double[][] data) { double[] lowerBound = {-0.5, 0.36}; double[] upperBound = {data[0].length, data.length * 0.87 + 0.5}; PlotCanvas canvas = new PlotCanvas(lowerBound, upperBound, false); canvas.add(new Hexmap(data)); canvas.getAxis(0).setFrameVisible(false); canvas.getAxis(0).setLabelVisible(false); canvas.getAxis(0).setGridVisible(false); canvas.getAxis(1).setFrameVisible(false); canvas.getAxis(1).setLabelVisible(false); canvas.getAxis(1).setGridVisible(false); return canvas; }
/** * Create a plot canvas with the pseudo hexmap plot of given data. * @param data a data matrix to be shown in hexmap. * @param palette the color palette. */ public static PlotCanvas plot(double[][] data, Color[] palette) { double[] lowerBound = {-0.5, 0.36}; double[] upperBound = {data[0].length, data.length * 0.87 + 0.5}; PlotCanvas canvas = new PlotCanvas(lowerBound, upperBound, false); canvas.add(new Hexmap(data, palette)); canvas.getAxis(0).setFrameVisible(false); canvas.getAxis(0).setLabelVisible(false); canvas.getAxis(0).setGridVisible(false); canvas.getAxis(1).setFrameVisible(false); canvas.getAxis(1).setLabelVisible(false); canvas.getAxis(1).setGridVisible(false); return canvas; }
/** * Create a plot canvas with the pseudo hexmap plot of given data. * @param labels the descriptions of each cell in the data matrix. * @param data a data matrix to be shown in hexmap. */ public static PlotCanvas plot(String[][] labels, double[][] data) { double[] lowerBound = {-0.5, 0.36}; double[] upperBound = {data[0].length, data.length * 0.87 + 0.5}; PlotCanvas canvas = new PlotCanvas(lowerBound, upperBound, false); canvas.add(new Hexmap(labels, data)); canvas.getAxis(0).setFrameVisible(false); canvas.getAxis(0).setLabelVisible(false); canvas.getAxis(0).setGridVisible(false); canvas.getAxis(1).setFrameVisible(false); canvas.getAxis(1).setLabelVisible(false); canvas.getAxis(1).setGridVisible(false); return canvas; }
/** * Create a plot canvas with the pseudo heat map plot of given data. * @param z a data matrix to be shown in pseudo heat map. */ 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 Heatmap(z)); canvas.getAxis(0).setFrameVisible(false); canvas.getAxis(0).setLabelVisible(false); canvas.getAxis(0).setGridVisible(false); canvas.getAxis(1).setFrameVisible(false); canvas.getAxis(1).setLabelVisible(false); canvas.getAxis(1).setGridVisible(false); 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 pseudo heat map plot of given data. * @param z a data matrix to be shown in pseudo heat map. * @param palette the color palette. */ public static PlotCanvas plot(double[][] z, Color[] palette) { double[] lowerBound = {0, 0}; double[] upperBound = {z[0].length, z.length}; PlotCanvas canvas = new PlotCanvas(lowerBound, upperBound, false); canvas.add(new Heatmap(z, palette)); canvas.getAxis(0).setFrameVisible(false); canvas.getAxis(0).setLabelVisible(false); canvas.getAxis(0).setGridVisible(false); canvas.getAxis(1).setFrameVisible(false); canvas.getAxis(1).setLabelVisible(false); canvas.getAxis(1).setGridVisible(false); return canvas; }
/** * Create a plot canvas with the pseudo hexmap plot of given data. * @param labels the descriptions of each cell in the data matrix. * @param data a data matrix to be shown in hexmap. * @param palette the color palette. */ public static PlotCanvas plot(String[][] labels, double[][] data, Color[] palette) { double[] lowerBound = {-0.5, 0.36}; double[] upperBound = {data[0].length, data.length * 0.87 + 0.5}; PlotCanvas canvas = new PlotCanvas(lowerBound, upperBound, false); canvas.add(new Hexmap(labels, data, palette)); canvas.getAxis(0).setFrameVisible(false); canvas.getAxis(0).setLabelVisible(false); canvas.getAxis(0).setGridVisible(false); canvas.getAxis(1).setFrameVisible(false); canvas.getAxis(1).setLabelVisible(false); canvas.getAxis(1).setGridVisible(false); 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; }
/** * Create a dendrogram plot. * @param merge an n-1 by 2 matrix of which row i describes the merging of clusters at * step i of the clustering. If an element j in the row is less than n, then * observation j was merged at this stage. If j ≥ n then the merge * was with the cluster formed at the (earlier) stage j-n of the algorithm. * @param height a set of n-1 non-decreasing real values, which are the clustering height, * i.e., the value of the criterion associated with the clustering method * for the particular agglomeration. */ public static PlotCanvas plot(int[][] merge, double[] height) { int n = merge.length + 1; Dendrogram dendrogram = new Dendrogram(merge, height); double[] lowerBound = {-n / 100, 0}; double[] upperBound = {n + n / 100, 1.01 * dendrogram.getHeight()}; PlotCanvas canvas = new PlotCanvas(lowerBound, upperBound, false); canvas.getAxis(0).setGridVisible(false); canvas.getAxis(0).setLabelVisible(false); canvas.add(dendrogram); return canvas; }
/** * Create a plot canvas with the histogram plot. * @param id the id of the plot. * @param data a sample set. */ public static PlotCanvas plot(String id, int[] data) { Histogram histogram = new Histogram(data); histogram.setID(id); 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]; } } PlotCanvas canvas = new PlotCanvas(lowerBound, upperBound); canvas.getAxis(0).setGridVisible(false); canvas.add(histogram); return canvas; }
/** * Create a plot canvas with the histogram plot of given data. * @param id the id of the plot. * @param data a sample set. * @param k the number of bins. */ public static PlotCanvas plot(String id, int[] data, int k) { Histogram histogram = new Histogram(data, k); histogram.setID(id); 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]; } } PlotCanvas canvas = new PlotCanvas(lowerBound, upperBound); canvas.getAxis(0).setGridVisible(false); canvas.add(histogram); return canvas; }
/** * Create a plot canvas with the bar plot of given data. * @param id the id of the plot. * @param data a vector of which values will determine the heights of bars. */ 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; }