plot bugs

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

plot bugs

Fred Damen
Greetings,

The below code demonstrates three bugs with plots:

1) Run as is, the IJ.log print pw=Title. By uncommenting the second set of
comments the IJ.log prints pw=null.

2) Run as is, the x-label is completely visible.  With the first set of
comments uncommented the x-label has its bottom chopped off.

3) run as is on a MacOS High Sierra (1.52b34) the window seems appropriate but
the plot itself seems to scaled to 4 times the area as it should be.  If you
uncomment the second set of commented lines the plot itself is scaled
correctly.  Or, if you dynamically change the size of the plot window the plot
itself rescales to what it should be.  Note that if you were to pass the plot
object to a subsequent call to drawPlot the plot would not retain the correct
scaling.
1.1) independent of the OS brand the subsequent plots produced using drawPlot
do not retain what was set using the 'more>>' options.

Thanks for listening,

Fred

-----------
import ij.*;
import ij.process.*;
import ij.gui.*;
import java.awt.*;
import ij.plugin.*;
import ij.plugin.frame.*;

public class TestAddToStack implements PlugIn {

   public void run(String arg) {
      Plot plot = new Plot("Title", "X", "Y");
      //plot.setFont(new Font("Comic Sans MS", Font.PLAIN, 12));
      //plot.setXLabelFont(new Font("Comic Sans MS", Font.PLAIN, 16));
      //plot.setYLabelFont(new Font("Comic Sans MS", Font.PLAIN, 16));
      plot.addPoints(new float[]{1,2,3}, new float[]{1,2,3},Plot.BOX);
      plot.addToStack();
      //plot.addPoints(new float[]{1,2,3}, new float[]{1,2,3},Plot.BOX);
      //plot.addToStack();
      PlotWindow pw = plot.show();
      IJ.log("pw="+pw);
      }

}

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: plot bugs

Michael Schmid
Hi Fred,

well, I can't give a good answer for all points; nevertheless I try:

(1) plot.show() returns the PlotWindow only for single plots. If there
is a PlotVirtualStack, the window is not a PlotWindow but a StackWindow.
To keep compatibility with previous versions, the code cannot be changed
to return the StackWindow of a plot stack.

So the only thing that can be done here is changing the documentation.

(2) The algorithm for setting the margin size is rather crude. It simply
takes the font size of the plot (i.e., the numbers), and assumes that
the axis labels are not too much larger.

In addition, "Comic Sans MS" is a strange font. For all other fonts that
I am aware of, the height of the characters above the baseline
("ascent") is less than the font size or equal at most; for Comic Sans
MS it is more!  Maybe because that font comes from Microsoft?

Among the fonts that I had tested, apart from "Comic Sans MS" the only
problematic one is the rather unusual "Tlwg Typo", where characters
reaching below the baseline (such as 'g') are cropped.

I tried a dozen other fonts with more reasonable metrics, there it still
fits with a number size of 12 and a label size of 16, with the exception
of the rather rare "Tlwg Typo" (but even that one has an ascent less
than the nominal size).

One could fix this issue, but it would change the appearance of plots
also with other unproblematic fonts, and I this would be unwanted for
users who have previously created and want new plots having the same
format, e.g. for making a panel out of them.  So I have no really good
solution at the moment.


(3) MacOS High Sierra: sorry, I have no computer with that system.
Sounds like one of the many Mac Java bugs...


(1.1): For plot stacks, there should be no "List", "More>>" etc buttons
at the bottom, so you cannot change settings (fonts, data range...) anyhow.

For other plots that newly created: Each plot is independent; plots
don't inherit properties of plots created previously.
The only exception is the "Plot Options" (Plot size, font size, grid &
ticks on/off).

If you do Java programming, there is a "useTemplate" method, which
transfers such options from another plot to the current one.
Currently it is only used for the 'Live' mode of profiles etc.


Best,

Michael
________________________________________________________________
On 18/05/2018 00:44, Fred Damen wrote:

> Greetings,
>
> The below code demonstrates three bugs with plots:
>
> 1) Run as is, the IJ.log print pw=Title. By uncommenting the second set of
> comments the IJ.log prints pw=null.
>
> 2) Run as is, the x-label is completely visible.  With the first set of
> comments uncommented the x-label has its bottom chopped off.
>
> 3) run as is on a MacOS High Sierra (1.52b34) the window seems appropriate but
> the plot itself seems to scaled to 4 times the area as it should be.  If you
> uncomment the second set of commented lines the plot itself is scaled
> correctly.  Or, if you dynamically change the size of the plot window the plot
> itself rescales to what it should be.  Note that if you were to pass the plot
> object to a subsequent call to drawPlot the plot would not retain the correct
> scaling.
> 1.1) independent of the OS brand the subsequent plots produced using drawPlot
> do not retain what was set using the 'more>>' options.
>
> Thanks for listening,
>
> Fred
>
> -----------
> import ij.*;
> import ij.process.*;
> import ij.gui.*;
> import java.awt.*;
> import ij.plugin.*;
> import ij.plugin.frame.*;
>
> public class TestAddToStack implements PlugIn {
>
>     public void run(String arg) {
>        Plot plot = new Plot("Title", "X", "Y");
>        //plot.setFont(new Font("Comic Sans MS", Font.PLAIN, 12));
>        //plot.setXLabelFont(new Font("Comic Sans MS", Font.PLAIN, 16));
>        //plot.setYLabelFont(new Font("Comic Sans MS", Font.PLAIN, 16));
>        plot.addPoints(new float[]{1,2,3}, new float[]{1,2,3},Plot.BOX);
>        plot.addToStack();
>        //plot.addPoints(new float[]{1,2,3}, new float[]{1,2,3},Plot.BOX);
>        //plot.addToStack();
>        PlotWindow pw = plot.show();
>        IJ.log("pw="+pw);
>        }
>
> }
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: plot bugs

Fred Damen
Greetings, see inline responses, Thanks Fred

On Fri, May 18, 2018 12:56 pm, Michael Schmid wrote:

> Hi Fred,
>
> well, I can't give a good answer for all points; nevertheless I try:
>
> (1) plot.show() returns the PlotWindow only for single plots. If there
> is a PlotVirtualStack, the window is not a PlotWindow but a StackWindow.
> To keep compatibility with previous versions, the code cannot be changed
> to return the StackWindow of a plot stack.
>
> So the only thing that can be done here is changing the documentation.
I only need to do a setLocation on the window that is produced.  When there
are more than one stacked plot the pointer to the window that is returned is
null.

>
> (2) The algorithm for setting the margin size is rather crude. It simply
> takes the font size of the plot (i.e., the numbers), and assumes that
> the axis labels are not too much larger.
>
> In addition, "Comic Sans MS" is a strange font. For all other fonts that
> I am aware of, the height of the characters above the baseline
> ("ascent") is less than the font size or equal at most; for Comic Sans
> MS it is more!  Maybe because that font comes from Microsoft?
>
> Among the fonts that I had tested, apart from "Comic Sans MS" the only
> problematic one is the rather unusual "Tlwg Typo", where characters
> reaching below the baseline (such as 'g') are cropped.
>
> I tried a dozen other fonts with more reasonable metrics, there it still
> fits with a number size of 12 and a label size of 16, with the exception
> of the rather rare "Tlwg Typo" (but even that one has an ascent less
> than the nominal size).
>
> One could fix this issue, but it would change the appearance of plots
> also with other unproblematic fonts, and I this would be unwanted for
> users who have previously created and want new plots having the same
> format, e.g. for making a panel out of them.  So I have no really good
> solution at the moment.
>
>
> (3) MacOS High Sierra: sorry, I have no computer with that system.
> Sounds like one of the many Mac Java bugs...
Is there a method that can be called that would trigger the redraw that
happens when the window is dynamically resized?

>
>
> (1.1): For plot stacks, there should be no "List", "More>>" etc buttons
> at the bottom, so you cannot change settings (fonts, data range...) anyhow.
>
> For other plots that newly created: Each plot is independent; plots
> don't inherit properties of plots created previously.
> The only exception is the "Plot Options" (Plot size, font size, grid &
> ticks on/off).
>
> If you do Java programming, there is a "useTemplate" method, which
> transfers such options from another plot to the current one.
> Currently it is only used for the 'Live' mode of profiles etc.
The use case that I am interested is in a live/dynamic plotting situation
where the user has selected to fix the range and a subsequent call to drawPlot
ignores the these setting.  When changing what is being plotted, e.g., moving
an roi, I would like to only look at the curve to see the change in intensity
instead of looking at both the axis and the curve.  The plot window interface
is really intuitive and has the gui for setting and fixing the axis range, but
does not seem to carry this to the subsequent drawPlot, and/or, I can not
figure out how to query the fact that the user wants the range fixed.

>
>
> Best,
>
> Michael
> ________________________________________________________________
> On 18/05/2018 00:44, Fred Damen wrote:
>> Greetings,
>>
>> The below code demonstrates three bugs with plots:
>>
>> 1) Run as is, the IJ.log print pw=Title. By uncommenting the second set of
>> comments the IJ.log prints pw=null.
>>
>> 2) Run as is, the x-label is completely visible.  With the first set of
>> comments uncommented the x-label has its bottom chopped off.
>>
>> 3) run as is on a MacOS High Sierra (1.52b34) the window seems appropriate
>> but
>> the plot itself seems to scaled to 4 times the area as it should be.  If you
>> uncomment the second set of commented lines the plot itself is scaled
>> correctly.  Or, if you dynamically change the size of the plot window the
>> plot
>> itself rescales to what it should be.  Note that if you were to pass the
>> plot
>> object to a subsequent call to drawPlot the plot would not retain the
>> correct
>> scaling.
>> 1.1) independent of the OS brand the subsequent plots produced using
>> drawPlot
>> do not retain what was set using the 'more>>' options.
>>
>> Thanks for listening,
>>
>> Fred
>>
>> -----------
>> import ij.*;
>> import ij.process.*;
>> import ij.gui.*;
>> import java.awt.*;
>> import ij.plugin.*;
>> import ij.plugin.frame.*;
>>
>> public class TestAddToStack implements PlugIn {
>>
>>     public void run(String arg) {
>>        Plot plot = new Plot("Title", "X", "Y");
>>        //plot.setFont(new Font("Comic Sans MS", Font.PLAIN, 12));
>>        //plot.setXLabelFont(new Font("Comic Sans MS", Font.PLAIN, 16));
>>        //plot.setYLabelFont(new Font("Comic Sans MS", Font.PLAIN, 16));
>>        plot.addPoints(new float[]{1,2,3}, new float[]{1,2,3},Plot.BOX);
>>        plot.addToStack();
>>        //plot.addPoints(new float[]{1,2,3}, new float[]{1,2,3},Plot.BOX);
>>        //plot.addToStack();
>>        PlotWindow pw = plot.show();
>>        IJ.log("pw="+pw);
>>        }
>>
>> }
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html