/** Sets the x-axis and y-axis range. * @deprecated use the corresponding method of the Plot class */ public void setLimits(double xMin, double xMax, double yMin, double yMax) { plot.setLimits(xMin, xMax, yMin, yMax); }
/** For "Add from Table" and "Add from Arrays" adds item to the plot according to the current Choice settings * and sets the Style fields for it. */ private void addObjectFromTable() { float[][] data = getDataArrays(); if (data[1] == null) return; //no y data? then can't plot String label = columnChoice[1].getSelectedItem(); //take label from y int shape = Plot.toShape(symbolChoice.getSelectedItem()); float lineWidth = (float)(Tools.parseDouble(widthField.getText())); if (lineWidth > 0) plot.setLineWidth(lineWidth); plot.restorePlotObjects(); if (savedLimits != null) plot.setLimits(savedLimits); plot.setColor(colorField.getText(), color2Field.getText()); plot.addPoints(data[0], data[1], data[3], shape, label); if (data[2] != null) plot.addHorizontalErrorBars(data[2]); if (creatingPlot) { plot.setXYLabels(data[0]==null ? "x" : columnChoice[0].getSelectedItem(), columnChoice[1].getSelectedItem()); plot.setLimitsToFit(false); } else plot.fitRangeToLastPlotObject(); currentObjectIndex = plot.getNumPlotObjects()-1; setDialogStyleFields(currentObjectIndex); if (dialogType == ADD_FROM_TABLE) previousTableName = allTableNames[tableChoice.getSelectedIndex()]; }
public static double[] setLimits(Plot plot, double minX, double maxX, double minY, double maxY) { double marginX = minX != maxX ? (maxX - minX) * 0.05 : 1; double marginY = minY != maxY ? (maxY - minY) * 0.05 : 1; plot.setLimits(minX - marginX, maxX + marginX, minY - marginY, maxY + marginY); return new double[] { minX - marginX, maxX + marginX, minY - marginY, maxY + marginY }; }
/** For "Add from Table" and "Add from Arrays" adds item to the plot according to the current Choice settings * and sets the Style fields for it. */ private void addObjectFromTable() { float[][] data = getDataArrays(); if (data[1] == null) return; //no y data? then can't plot String label = columnChoice[1].getSelectedItem(); //take label from y int shape = Plot.toShape(symbolChoice.getSelectedItem()); float lineWidth = (float)(Tools.parseDouble(widthField.getText())); if (lineWidth > 0) plot.setLineWidth(lineWidth); plot.restorePlotObjects(); if (savedLimits != null) plot.setLimits(savedLimits); plot.setColor(colorField.getText(), color2Field.getText()); plot.addPoints(data[0], data[1], data[3], shape, label); if (data[2] != null) plot.addHorizontalErrorBars(data[2]); if (creatingPlot) { plot.setXYLabels(data[0]==null ? "x" : columnChoice[0].getSelectedItem(), columnChoice[1].getSelectedItem()); plot.setLimitsToFit(false); } else plot.fitRangeToLastPlotObject(); currentObjectIndex = plot.getNumPlotObjects()-1; setDialogStyleFields(currentObjectIndex); if (dialogType == ADD_FROM_TABLE) previousTableName = allTableNames[tableChoice.getSelectedIndex()]; }
/** Sets the x-axis and y-axis range. * @deprecated use the corresponding method of the Plot class */ public void setLimits(double xMin, double xMax, double yMin, double yMax) { plot.setLimits(xMin, xMax, yMin, yMax); }
/** * Create plot with the precision-recall curve * @param stats classification statistics * @return precision-recall plot */ public static Plot createPrecisionRecallPlot( ArrayList< ClassificationStatistics > stats) { // Extract precision and recall values float[] precision = new float[ stats.size() ]; float[] recall = new float[ stats.size() ]; for(int i = 0; i < precision.length; i++) { precision[i] = (float) stats.get(i).precision; recall[i] = (float) stats.get(i).recall; } Plot pl = new Plot("Precision-Recall curve", "Recall [tp / (tp + fn)]", "Precision [tp / (tp+fp)]", recall, precision); pl.setLimits(0, 1, 0, 1); pl.setSize(540, 512); pl.setColor(Color.GREEN); return pl; }
/** * Create plot with the precision-recall curve * @param stats classification statistics * @return precision-recall plot */ public static Plot createPrecisionRecallPlot( ArrayList< ClassificationStatistics > stats) { // Extract precision and recall values float[] precision = new float[ stats.size() ]; float[] recall = new float[ stats.size() ]; for(int i = 0; i < precision.length; i++) { precision[i] = (float) stats.get(i).precision; recall[i] = (float) stats.get(i).recall; } Plot pl = new Plot("Precision-Recall curve", "Recall [tp / (tp + fn)]", "Precision [tp / (tp+fp)]", recall, precision); pl.setLimits(0, 1, 0, 1); pl.setSize(540, 512); pl.setColor(Color.GREEN); return pl; }
/** * Plot the Receiver operating characteristic curve * @param stats classification statistics */ public static void plotROC( ArrayList< ClassificationStatistics > stats) { // Extract true positive and true negative rates float[] tpr = new float[ stats.size() ]; float[] fpr = new float[ stats.size() ]; for(int i = 0; i < tpr.length; i++) { tpr[i] = (float) stats.get(i).recall; fpr[i] = (float) (1f - stats.get(i).specificity); } Plot pl = new Plot("Receiver Operating Characteristic curve", "False Positive Rate (1 - specificity)", "True Positive Rate or sensitivity", fpr, tpr ); pl.setLimits(0, 1, 0, 1); pl.setSize(540, 512); pl.setColor(Color.RED); pl.show(); }
/** * Plot the precision-recall curve * @param stats classification statistics */ public static void plotPrecisionRecall( ArrayList< ClassificationStatistics > stats) { // Extract precision and recall values float[] precision = new float[ stats.size() ]; float[] recall = new float[ stats.size() ]; for(int i = 0; i < precision.length; i++) { precision[i] = (float) stats.get(i).precision; recall[i] = (float) stats.get(i).recall; } Plot pl = new Plot("Precision-Recall curve", "Recall [tp / (tp + fn)]", "Precision [tp / (tp+fp)]", recall, precision); pl.setLimits(0, 1, 0, 1); pl.setSize(540, 512); pl.setColor(Color.GREEN); pl.show(); }
/** * Plot the Receiver operating characteristic curve * @param stats classification statistics */ public static void plotROC( ArrayList< ClassificationStatistics > stats) { // Extract true positive and true negative rates float[] tpr = new float[ stats.size() ]; float[] fpr = new float[ stats.size() ]; for(int i = 0; i < tpr.length; i++) { tpr[i] = (float) stats.get(i).recall; fpr[i] = (float) (1f - stats.get(i).specificity); } Plot pl = new Plot("Receiver Operating Characteristic curve", "False Positive Rate (1 - specificity)", "True Positive Rate or sensitivity", fpr, tpr ); pl.setLimits(0, 1, 0, 1); pl.setSize(540, 512); pl.setColor(Color.RED); pl.show(); }
/** * Plot the precision-recall curve * @param stats classification statistics */ public static void plotPrecisionRecall( ArrayList< ClassificationStatistics > stats) { // Extract precision and recall values float[] precision = new float[ stats.size() ]; float[] recall = new float[ stats.size() ]; for(int i = 0; i < precision.length; i++) { precision[i] = (float) stats.get(i).precision; recall[i] = (float) stats.get(i).recall; } Plot pl = new Plot("Precision-Recall curve", "Recall [tp / (tp + fn)]", "Precision [tp / (tp+fp)]", recall, precision); pl.setLimits(0, 1, 0, 1); pl.setSize(540, 512); pl.setColor(Color.GREEN); pl.show(); }
public Plot getPlot() { if (profile==null) return null; String xLabel = "Distance ("+units+")"; int n = profile.length; if (xValues==null) { xValues = new float[n]; for (int i=0; i<n; i++) xValues[i] = (float)(i*xInc); } float[] yValues = new float[n]; for (int i=0; i<n; i++) yValues[i] = (float)profile[i]; boolean fixedYScale = fixedMin!=0.0 || fixedMax!=0.0; Plot plot = new Plot("Plot of "+getShortTitle(imp), xLabel, yLabel, xValues, yValues); if (fixedYScale) { double[] a = Tools.getMinMax(xValues); plot.setLimits(a[0],a[1],fixedMin,fixedMax); } return plot; }
public Plot getPlot() { if (profile==null) return null; String xLabel = "Distance ("+units+")"; int n = profile.length; if (xValues==null) { xValues = new float[n]; for (int i=0; i<n; i++) xValues[i] = (float)(i*xInc); } float[] yValues = new float[n]; for (int i=0; i<n; i++) yValues[i] = (float)profile[i]; boolean fixedYScale = fixedMin!=0.0 || fixedMax!=0.0; Plot plot = new Plot("Plot of "+getShortTitle(imp), xLabel, yLabel, xValues, yValues); if (fixedYScale) { double[] a = Tools.getMinMax(xValues); plot.setLimits(a[0],a[1],fixedMin,fixedMax); } return plot; }
/** For "Add from Plot", adds item to the plot according to the current Choice settings * and sets the Style fields for it. */ private void addObjectFromPlot() { int plotIndex = plotChoice.getSelectedIndex(); int objectIndex = objectChoice.getSelectedIndex(); plot.restorePlotObjects(); if (savedLimits != null) plot.setLimits(savedLimits); currentObjectIndex = plot.addObjectFromPlot(allPlots[plotIndex], objectIndex); //no updateImage; will be done later plot.fitRangeToLastPlotObject(); setDialogStyleFields(currentObjectIndex); previousPlot = allPlots[plotIndex]; previousPlotObjectIndex = objectIndex; }
/** For "Add from Plot", adds item to the plot according to the current Choice settings * and sets the Style fields for it. */ private void addObjectFromPlot() { int plotIndex = plotChoice.getSelectedIndex(); int objectIndex = objectChoice.getSelectedIndex(); plot.restorePlotObjects(); if (savedLimits != null) plot.setLimits(savedLimits); currentObjectIndex = plot.addObjectFromPlot(allPlots[plotIndex], objectIndex); //no updateImage; will be done later plot.fitRangeToLastPlotObject(); setDialogStyleFields(currentObjectIndex); previousPlot = allPlots[plotIndex]; previousPlotObjectIndex = objectIndex; }
/** Plots a histogram of this image using the specified number of bins and returns the PlotWindow. */ public PlotWindow plotHistogram(int bins) { ImageStatistics stats = getStatistics(AREA+MEAN+MODE+MIN_MAX, bins); Plot plot = new Plot("Hist_"+getTitle(), "Value", "Frequency"); plot.setColor("black", "#999999"); plot.setFont(new Font("SansSerif",Font.PLAIN,14)); double[] y = stats.histogram(); int n = y.length; double[] x = new double[n]; int bits = getBitDepth(); boolean eightBit = bits==8 || bits==24; double min = !eightBit?stats.min:0; for (int i=0; i<n; i++) x[i] = min+i*stats.binSize; plot.add("bar", x, y); if (bins!=256) plot.addLegend(bins+" bins", "auto"); if (eightBit) plot.setLimits(0,256,0,Double.NaN); return plot.show(); }
ymax = Math.max(ymax, a[1]); Plot plot = new Plot("Plot", "log (box size)", "log (count)", px, py); plot.setLimits(xmin,xmax,ymin,ymax); plot.addPoints(sizes, boxCountSums, PlotWindow.CIRCLE); plot.addLabel(0.8, 0.2, label);
/** Plots a histogram of this image using the specified number of bins and returns the PlotWindow. */ public PlotWindow plotHistogram(int bins) { ImageStatistics stats = getStatistics(AREA+MEAN+MODE+MIN_MAX, bins); Plot plot = new Plot("Hist_"+getTitle(), "Value", "Frequency"); plot.setColor("black", "#999999"); plot.setFont(new Font("SansSerif",Font.PLAIN,14)); double[] y = stats.histogram(); int n = y.length; double[] x = new double[n]; int bits = getBitDepth(); boolean eightBit = bits==8 || bits==24; double min = !eightBit?stats.min:0; for (int i=0; i<n; i++) x[i] = min+i*stats.binSize; plot.add("bar", x, y); if (bins!=256) plot.addLegend(bins+" bins", "auto"); if (eightBit) plot.setLimits(0,256,0,Double.NaN); return plot.show(); }
plot.restorePlotObjects(); if (savedLimits != null) plot.setLimits(savedLimits); int dataIndex = fitDataChoice.getSelectedIndex(); float[][] data = plot.getDataObjectArrays(dataIndex);
static public Plot makePlot(final CATAParameters cp, final String name, final VectorString3D c) { final double[] stdDev = c.getStdDevAtEachPoint(); if (null == stdDev) return null; final double[] index = new double[stdDev.length]; for (int i=0; i<index.length; i++) index[i] = i; Utils.log2("name is " + name); Utils.log2("c is " + c); Utils.log2("cp is " + cp); Utils.log2("stdDev is " + stdDev); Utils.log2("c.getCalibrationCopy() is " + c.getCalibrationCopy()); Utils.log2("c.getDelta() is " + c.getDelta()); final Calibration cal = c.getCalibrationCopy(); if (null == cal) Utils.log2("WARNING null calibration!"); final Plot plot = new Plot(name, name + " -- Point index (delta: " + Utils.cutNumber(c.getDelta(), 2) + " " + (null == cal ? "pixels" : cal.getUnits()) + ")", "Std Dev", index, stdDev); plot.setLimits(0, cp.plot_max_x, 0, cp.plot_max_y); plot.setSize(cp.plot_width, cp.plot_height); plot.setLineWidth(2); return plot; }