Search in sources :

Example 41 with Plot2

use of ij.gui.Plot2 in project GDSC-SMLM by aherbert.

the class PCPALMMolecules method plot.

private double[][] plot(DoubleData stats, String label, boolean integerBins) {
    String title = TITLE + " " + label;
    Plot2 plot;
    double[][] hist = null;
    if (integerBins) {
        // The histogram is not need for the return statement
        Utils.showHistogram(title, stats, label, 1, 0, 0);
    } else {
        // Show a cumulative histogram so that the bin size is not relevant
        hist = Maths.cumulativeHistogram(stats.values(), false);
        // Create the axes
        double[] xValues = hist[0];
        double[] yValues = hist[1];
        // Plot
        plot = new Plot2(title, label, "Frequency", xValues, yValues);
        Utils.display(title, plot);
    }
    return hist;
}
Also used : Plot2(ij.gui.Plot2)

Example 42 with Plot2

use of ij.gui.Plot2 in project GDSC-SMLM by aherbert.

the class PCPALMAnalysis method plotCorrelation.

public static Plot2 plotCorrelation(double[][] gr, int offset, String plotTitle, String yAxisTitle, boolean barChart, boolean showErrorBars) {
    double[] x = new double[gr[1].length - offset];
    double[] y = new double[x.length];
    System.arraycopy(gr[0], offset, x, 0, x.length);
    System.arraycopy(gr[1], offset, y, 0, y.length);
    Plot2 plot = new Plot2(plotTitle, "r (nm)", yAxisTitle);
    plot.setLimits(0, x[x.length - 1], Maths.min(y) * 0.95, Maths.max(y) * 1.05);
    plot.addPoints(x, y, (barChart) ? Plot2.BAR : Plot.LINE);
    Utils.display(plotTitle, plot);
    if (showErrorBars && !barChart) {
        plot.setColor(Color.magenta);
        for (int i = 0; i < x.length; i++) {
            double sd = gr[2][i + offset];
            plot.drawLine(x[i], y[i] - sd, x[i], y[i] + sd);
        }
        Utils.display(plotTitle, plot);
    }
    return plot;
}
Also used : Plot2(ij.gui.Plot2)

Aggregations

Plot2 (ij.gui.Plot2)42 PlotWindow (ij.gui.PlotWindow)17 Point (java.awt.Point)9 BasePoint (gdsc.core.match.BasePoint)8 Statistics (gdsc.core.utils.Statistics)6 StoredDataStatistics (gdsc.core.utils.StoredDataStatistics)6 MemoryPeakResults (gdsc.smlm.results.MemoryPeakResults)5 WeightedObservedPoint (org.apache.commons.math3.fitting.WeightedObservedPoint)5 ClusterPoint (gdsc.core.clustering.ClusterPoint)4 PeakResultPoint (gdsc.smlm.ij.plugins.ResultsMatchCalculator.PeakResultPoint)4 PeakResult (gdsc.smlm.results.PeakResult)4 StoredData (gdsc.core.utils.StoredData)3 WindowOrganiser (ij.plugin.WindowOrganiser)3 Rectangle (java.awt.Rectangle)3 ArrayList (java.util.ArrayList)3 LoessInterpolator (org.apache.commons.math3.analysis.interpolation.LoessInterpolator)3 TooManyEvaluationsException (org.apache.commons.math3.exception.TooManyEvaluationsException)3 DescriptiveStatistics (org.apache.commons.math3.stat.descriptive.DescriptiveStatistics)3 Cluster (gdsc.core.clustering.Cluster)2 ClusteringEngine (gdsc.core.clustering.ClusteringEngine)2