Re: Update Plot window
Posted by
Michael Schmid on
Aug 18, 2009; 5:00pm
URL: http://imagej.273.s1.nabble.com/Update-Plot-window-tp3691438p3691439.html
Hi Michael,
instead of
plot.show()
you can use
plot.getProcessor();
and then in the corresponding ImagePlus (which must exist already)
update the image:
plotImagePlus.setProcessor(null, ip);
The Dynamic Profiler is an example for this:
http://rsbweb.nih.gov/ij/plugins/dynamic-profiler.htmlMichael
________________________________________________________________
On 18 Aug 2009, at 18:36, Michael Doube wrote:
> Hi all
>
> I have a plugin that iterates in a while loop until convergence
> occurs and I'd like to monitor the values graphically. I can draw
> a Plot of the values once the while loop has finished, but if I try
> to redraw the plot with multiple calls to my graphResults() method
> I get a rather large number of Plot windows.
>
> How can I update a plot window with new data? I'm collecting the Y
> data in a Vector (because I can add values to it in the while
> loop). My plotting method is as follows:
>
>
> private void graphResults(Vector<Double> anisotropyHistory){
> double[] yVariables = new double[anisotropyHistory.size()];
> double[] xVariables = new double[anisotropyHistory.size()];
> Enumeration<Double> e = anisotropyHistory.elements();
> int i = 0;
> while (e.hasMoreElements()){
> yVariables[i] = e.nextElement();
> xVariables[i] = (double)i;
> i++;
> }
> Plot plot = new Plot("Anisotropy", "Number of repeats", "Anisotropy",
> xVariables, yVariables);
> plot.addPoints(xVariables, yVariables, Plot.X);
> plot.setLimits(0, anisotropyHistory.size(), 0, 1);
> plot.show();
> }
>
>
> Michael