Java Code Examples for ij.gui.Plot#addPoints()

The following examples show how to use ij.gui.Plot#addPoints() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractCalibrationProcess.java    From thunderstorm with GNU General Public License v3.0 5 votes vote down vote up
protected static void drawSigmaPlots(Plot plot, double[] xVals, SigmaPlotConfig cfg) {
    // add points
    plot.setColor(cfg.allSigma1sColor);
    plot.addPoints(cfg.allFrames, cfg.allSigma1s, Plot.CROSS);
    plot.setColor(cfg.allSigma2sColor);
    plot.addPoints(cfg.allFrames, cfg.allSigma2s, Plot.CROSS);

    // add polynomials
    for(int i = 0; i < cfg.allPolynomsS1.size(); i++) {
        double[] sigma1Vals = new double[xVals.length];
        double[] sigma2Vals = new double[xVals.length];
        for(int j = 0; j < sigma1Vals.length; j++) {
            sigma1Vals[j] = cfg.allPolynomsS1.get(i).value(xVals[j]);
            sigma2Vals[j] = cfg.allPolynomsS2.get(i).value(xVals[j]);
        }
        plot.setColor(cfg.allPolynomsS1Color);
        plot.addPoints(xVals, sigma1Vals, Plot.LINE);
        plot.setColor(cfg.allPolynomsS2Color);
        plot.addPoints(xVals, sigma2Vals, Plot.LINE);
    }

    // add final fitted curves
    double[] sigma1ValsAll = new double[xVals.length];
    double[] sigma2ValsAll = new double[xVals.length];
    for(int j = 0; j < sigma1ValsAll.length; j++) {
        sigma1ValsAll[j] = cfg.polynomS1Final.value(xVals[j]);
        sigma2ValsAll[j] = cfg.polynomS2Final.value(xVals[j]);
    }
    plot.setColor(cfg.polynomS1FinalColor);
    plot.addPoints(xVals, sigma1ValsAll, Plot.LINE);
    plot.setColor(cfg.polynomS2FinalColor);
    plot.addPoints(xVals, sigma2ValsAll, Plot.LINE);

    //legend
    plot.setColor(cfg.polynomS1FinalColor);
    plot.addLabel(cfg.legend1X, cfg.legend1Y, cfg.legend1Label);
    plot.setColor(cfg.polynomS2FinalColor);
    plot.addLabel(cfg.legend2X, cfg.legend2Y, cfg.legend2Label);
}
 
Example 2
Source File: ResultsDriftCorrection.java    From thunderstorm with GNU General Public License v3.0 5 votes vote down vote up
public static void showDriftPlot(DriftResults driftCorrection) {
    int minFrame = driftCorrection.getMinFrame();
    int maxFrame = driftCorrection.getMaxFrame();
    int gridTicks = 200;
    double tickStep = (maxFrame - minFrame) / (double) gridTicks;
    double[] grid = new double[gridTicks];
    double[] driftX = new double[gridTicks];
    double[] driftY = new double[gridTicks];
    for(int i = 0; i < gridTicks; i++) {
        grid[i] = i * tickStep + minFrame;
        Point2D.Double offset = driftCorrection.getInterpolatedDrift(grid[i]);
        driftX[i] = offset.x;
        driftY[i] = offset.y;
    }
    Plot plot = new Plot("Drift", "frame", "drift [" + driftCorrection.getUnits() + "]", (float[]) null, null);
    if(driftCorrection.getDriftDataX().length > 50) {
        plot.setFrameSize(1280, 720);
    }
    plot.setLimits(minFrame, driftCorrection.getMaxFrame(),
            Math.min(VectorMath.min(driftCorrection.getDriftDataX()), VectorMath.min(driftCorrection.getDriftDataY())),
            Math.max(VectorMath.max(driftCorrection.getDriftDataX()), VectorMath.max(driftCorrection.getDriftDataY())));
    plot.setColor(new Color(255, 128, 128));
    plot.addPoints(driftCorrection.getDriftDataFrame(), driftCorrection.getDriftDataX(), Plot.CROSS);
    plot.draw();
    plot.setColor(new Color(128, 255, 128));
    plot.addPoints(driftCorrection.getDriftDataFrame(), driftCorrection.getDriftDataY(), Plot.CROSS);
    plot.setColor(Color.red);
    plot.addPoints(grid, driftX, Plot.LINE);
    plot.addLabel(0.05, 0.8, "x drift");
    plot.setColor(Color.green);
    plot.addPoints(grid, driftY, Plot.LINE);
    plot.addLabel(0.05, 0.9, "y drift");
    plot.show();
}