Re: Plot without lines?
Posted by Wayne Rasband on Dec 17, 2005; 8:55pm
URL: http://imagej.273.s1.nabble.com/Plot-without-lines-tp3704210p3704211.html
> Does anybody have a suggestion about how to produce a plot
> *without* the line connecting the data points?
Here is an example macro that creates scatter plot:
n = 5000;
x = newArray(n);
y = newArray(n);
for (i=0; i<n; i++) {
x[i] = i+n/3*(random()-0.5);
y[i] = i+n/3*(random()-0.5);
}
Plot.create("Scatter Plot", "X", "Y");
Plot.setLimits(0, n, 0, n);
Plot.add("dots", x, y);
In a plugin it would look like this:
int n = 5000;
double[] x = new double[n];
double[] y = new double[n];
Random ran = new Random();
for (int i=0; i<n; i++) {
x[i] = i+n/3.0*(ran.nextDouble()-0.5);
y[i] = i+n/3.0*(ran.nextDouble()-0.5);
}
Plot plot = new Plot("Scatter Plot", "X", "Y", new double[1],
new double[1]);
plot.setLimits(0, n, 0, n);
plot.addPoints(x, y, Plot.DOT);
plot.show();
-wayne