Hi Fred,

your data contain the value x=0. Thus, plot.setLimitsToFit forces the plot to include the value x=0, which forces the x axis to be linear, not logarithmic. If you have only positive data, or if you don't call setLimitsToFit, useTemplate with Plot.COPY_AXIS_STYLE keeps the axis logarithmic.

Michael
________________________________________________________________
On 25.01.24 00:42, Fred Damen wrote:
Greeting,

I am trying to maintain the logarithmic axis through successive plots, see
below. To reproduce, you...

Run the below plugin.
Click "Press me"
Choose More>> Set Range...
Set X From to 0.1
Set Log X Axis
Click OK
Click "Press me"
The X axis is no longer logarithmic.
Choosing More>> Set Range...
reveals that X From is now "0" again, albeit Log X Axis is still set...

Q: Is just X_RANGE required for my requirement, or is COPY_AXIS_STYLE also
required?

Fred



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

public class TestuseTemplate implements PlugIn {

    PlotWindow pwin = null;
    Plot prevPlot = null;
    public void run(String arg) {
       GenericDialog gd = new NonBlockingGenericDialog("test useTemplate");
       gd.addButton("Press me",new ActionListener() {
          public void actionPerformed(ActionEvent e) {
             Plot plot = new Plot("Title", "X", "Y");
             plot.addPoints(new float[]{0,10,100,1000},new 
float[]{0,10,100,1000},Plot.LINE);

             if (prevPlot != null)
                plot.useTemplate(prevPlot, 
Plot.COPY_SIZE+Plot.X_RANGE+Plot.COPY_AXIS_STYLE);

             if (pwin==null)
                pwin = plot.show();
             else
                pwin.drawPlot(plot);
             plot.setLimitsToFit(true);

             prevPlot = plot;
             }
          });
       gd.showDialog();
       }

}

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

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

Reply via email to