Package ij.gui

Class Plot

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class Plot
    extends java.lang.Object
    implements java.lang.Cloneable
    This class creates an image that line graphs, scatter plots and plots of vector fields (arrows) can be drawn on and displayed. Note that the clone() operation is a shallow clone: objects like arrays, the plot objects, the ImagePlus etc. of the clone remain the same as those of the original.
    Author:
    Wayne Rasband, Philippe CARL, CNRS, philippe.carl (AT) unistra.fr (log axes, arrows, ArrayList data), Michael Schmid (axis grid/ticks, resizing/panning/changing range, high-resolution)
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int AUTO_POSITION
      Legend positions
      static int BOTTOM_LEFT
      Legend positions
      static int BOTTOM_MARGIN
      Deprecated.
      Not a fixed value any more, use getDrawingFrame() to get the drawing area
      static int BOTTOM_RIGHT
      Legend positions
      static int BOX
      Display points using a square box-shaped mark.
      static int CENTER
      Text justification.
      static int CIRCLE
      Display points using a circle (5 pixels in diameter if line thickness<=1, otherwise 7).
      static int CONNECTED_CIRCLES
      Draw black lines between the dots and a circle with the given color at each dot
      static int COPY_LABELS
      Flag for copying from a template: copy text of axis labels
      static int COPY_LEGEND
      Flag for copying from a template: copy legend
      static int COPY_SIZE
      Flag for copying from a template: copy text of axis labels
      static int CROSS
      Display points using an cross-shaped mark.
      static int DEFAULT_FLAGS
      The default flags, will be modified by PlotWindow.noGridLines and PlotWindow.noTicks (see getDefaultFlags)
      static int DOT
      Display points using a single pixel.
      static int LEFT
      Text justification.
      static int LEFT_MARGIN
      Deprecated.
      Not a fixed value any more, use getDrawingFrame() to get the drawing area
      static int LEGEND_BOTTOM_UP
      Legend has its curves in bottom-to-top sequence (otherwise top to bottom)
      static int LEGEND_TRANSPARENT
      Legend erases background (otherwise transparent)
      static int LINE
      Connect points with solid lines.
      static int MIN_FRAMEHEIGHT
      minimum width of frame area in plot
      static int MIN_FRAMEWIDTH
      minimum width of frame area in plot
      static java.lang.String PROPERTY_KEY
      key in ImagePlus properties to access the plot behind an ImagePlus
      static int RIGHT
      Text justification.
      static int RIGHT_MARGIN
      Deprecated.
      Not a fixed value any more, use getDrawingFrame() to get the drawing area
      static int TOP_LEFT
      Legend positions
      static int TOP_MARGIN
      Deprecated.
      Not a fixed value any more, use getDrawingFrame() to get the drawing area
      static int TOP_RIGHT
      Legend positions
      static int TRIANGLE
      Display points using an tiangular mark.
      static int X
      Display points using an X-shaped mark.
      static int X_FORCE2GRID
      flag for forcing frame to coincide with the grid/ticks in x direction (results in unused space)
      static int X_GRID
      flag for drawing vertical grid lines for x axis
      static int X_LOG_NUMBERS
      flag for logarithmic x-axis
      static int X_LOG_TICKS
      flag for ticks (major and minor, if space) on logarithmic x axis
      static int X_MINOR_TICKS
      flag for drawing minor ticks on linear (non-logarithmic) x axis
      static int X_NUMBERS
      flag for numeric labels of x-axis ticks
      static int X_RANGE
      Flag for copying from a template: copy x axis range.
      static int X_TICKS
      flag for drawing major ticks on linear (non-logarithmic) x axis
      static int Y_FORCE2GRID
      flag for forcing frame to coincide with the grid/ticks in y direction (results in unused space)
      static int Y_GRID
      flag for drawing horizontal grid lines for y axis
      static int Y_LOG_NUMBERS
      flag for logarithmic y axis
      static int Y_LOG_TICKS
      flag for ticks (major and minor, if space) on logarithmic y axis
      static int Y_MINOR_TICKS
      flag for drawing minor ticks on linear (non-logarithmic) y axis
      static int Y_NUMBERS
      flag for numeric labels of x-axis ticks
      static int Y_RANGE
      Flag for copying from a template: copy y axis range
      static int Y_TICKS
      flag for drawing major ticks on linear (non-logarithmic) y axis
    • Constructor Summary

      Constructors 
      Constructor Description
      Plot​(java.lang.String title, java.lang.String xLabel, java.lang.String yLabel)
      This is a version of the constructor with no intial arrays.
      Plot​(java.lang.String title, java.lang.String xLabel, java.lang.String yLabel, double[] xValues, double[] yValues)
      This version of the constructor accepts double arrays.
      Plot​(java.lang.String title, java.lang.String xLabel, java.lang.String yLabel, double[] xValues, double[] yValues, int flags)
      This version of the constructor accepts double arrays and has a 'flags' argument.
      Plot​(java.lang.String title, java.lang.String xLabel, java.lang.String yLabel, float[] xValues, float[] yValues)
      Construct a new PlotWindow.
      Plot​(java.lang.String title, java.lang.String xLabel, java.lang.String yLabel, float[] xValues, float[] yValues, int flags)
      This version of the constructor has a 'flags' argument for controlling the appearance of ticks, grid, etc.
      Plot​(java.lang.String title, java.lang.String xLabel, java.lang.String yLabel, int flags)
      This is a version of the constructor with no intial arrays.
      Plot​(java.lang.String dummy, java.lang.String title, java.lang.String xLabel, java.lang.String yLabel, float[] xValues, float[] yValues)
      This is a constructor that works with JavaScript.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(java.lang.String shape, double[] x, double[] y)  
      void addErrorBars​(double[] errorBars)
      Adds vertical error bars to the last data passed to the plot (via the constructor or addPoints).
      void addErrorBars​(float[] errorBars)
      Adds vertical error bars to the last data passed to the plot (via the constructor or addPoints).
      void addErrorBars​(java.lang.String dummy, float[] errorBars)
      This is a version of addErrorBars that works with JavaScript.
      void addHorizontalErrorBars​(double[] xErrorBars)
      Adds horizontal error bars to the last data passed to the plot (via the constructor or addPoints).
      void addLabel​(double x, double y, java.lang.String label)
      Draws text at the specified location, where (0,0) is the upper left corner of the the plot frame and (1,1) is the lower right corner.
      void addLegend​(java.lang.String labels)
      Adds an automatically positioned legend, where 'labels' is a newline-delimited list of curve or point lables.
      void addLegend​(java.lang.String labels, java.lang.String options)  
      void addPoints​(double[] x, double[] y, double[] errorBars, int shape)
      Adds a set of points to the plot or adds a curve if shape is set to LINE.
      void addPoints​(double[] x, double[] y, int shape)
      Adds a set of points to the plot using double arrays.
      void addPoints​(float[] xValues, float[] yValues, float[] yErrorBars, int shape, java.lang.String label)
      Adds a set of points to the plot or adds a curve if shape is set to LINE.
      void addPoints​(float[] x, float[] y, int shape)
      Adds a set of points to the plot or adds a curve if shape is set to LINE.
      void addPoints​(java.lang.String dummy, float[] x, float[] y, int shape)
      This a version of addPoints that works with JavaScript.
      void addPoints​(java.util.ArrayList x, java.util.ArrayList y, int shape)
      Adds a set of points to the plot using double ArrayLists.
      void addPoints​(java.util.ArrayList x, java.util.ArrayList y, java.util.ArrayList z, int shape)
      Adds a set of points to the plot using double ArrayLists.
      void addText​(java.lang.String label, double x, double y)  
      void adjustCalibration​(Calibration cal)
      Adjusts a Calibration object to fit the current axes.
      static double calculateDistance​(int x1, int y1, int x2, int y2)  
      void changeFont​(java.awt.Font font)
      Obsolete; replaced by setFont().
      double descaleX​(int x)
      Converts pixels to calibrated coordinates.
      double descaleY​(int y)
      Converts pixels to calibrated coordinates.
      void dispose()
      Releases the ImageProcessor and ImagePlus associated with the plot.
      void draw()
      Draws the plot specified for the first time.
      void drawArrow​(int x1, int y1, int x2, int y2, double size)
      Adds an arrow from position 1 to 2 given in pixels; 'size' is the length of the arrowhead WARNING: Use as a public method is not supported any more because it is incompatible with rescaling
      void drawDottedLine​(double x1, double y1, double x2, double y2, int step)  
      void drawLine​(double x1, double y1, double x2, double y2)  
      void drawNormalizedLine​(double x1, double y1, double x2, double y2)
      Draws a line using a normalized 0-1, 0-1 coordinate system, with (0,0) at the top left and (1,1) at the lower right corner.
      void drawVectors​(double[] x1, double[] y1, double[] x2, double[] y2)
      Adds a set of points that will be drawn as ARROWs.
      void drawVectors​(java.util.ArrayList x1, java.util.ArrayList y1, java.util.ArrayList x2, java.util.ArrayList y2)
      Adds a set of vectors to the plot using double ArrayLists.
      static int getDefaultFlags()
      The default flags, taking PlotWindow.noGridLines, PlotWindow.noTicks into account
      double[] getDoubleFromArrayList​(java.util.ArrayList list)  
      java.awt.Rectangle getDrawingFrame()
      Returns the rectangle where the data are plotted.
      int getFlags()
      Returns the flags that control the axes
      ImagePlus getImagePlus()
      Returns the plot as an ImagePlus.
      double[] getLimits()
      Returns the current limits as an array xMin, xMax, yMin, yMax.
      java.awt.Dimension getMinimumSize()
      The minimum plot size including borders, in pixels (at scale=1)
      ImageProcessor getProcessor()
      Draws the plot (if not done before) in an ImageProcessor and returns the ImageProcessor with the plot.
      ResultsTable getResultsTable()
      Creates a ResultsTable with the plot data.
      ResultsTable getResultsTable​(boolean writeFirstXColumn)
      Creates a ResultsTable with the data of the plot.
      java.awt.Dimension getSize()
      The size of the plot including borders with axis labels etc., in pixels
      java.lang.String getTitle()
      Returns the title of the image showing the plot (if any) or title of the plot
      float[] getXValues()
      Get the x coordinates of the data set passed with the constructor (if not null) or otherwise of the data set of the first 'addPoints'.
      float[] getYValues()
      Get the y coordinates of the data set passed with the constructor (if not null) or otherwise of the data set of the first 'addPoints'.
      boolean isFrozen()  
      ImagePlus makeHighResolution​(java.lang.String title, float scale, boolean antialiasedText, boolean showIt)
      Creates a new high-resolution plot by scaling it and displays that plot if showIt is true.
      double scaleXtoPxl​(double x)
      Converts calibrated coordinates to pixel coordinates.
      double scaleYtoPxl​(double y)
      Converts calibrated coordinates to pixel coordinates.
      void setAntialiasedText​(boolean antialiasedText)
      Determines whether to use antialiased text (default true)
      void setAxes​(boolean xLog, boolean yLog, boolean xTicks, boolean yTicks, boolean xMinorTicks, boolean yMinorTicks, int tickLenght, int minorTickLenght)
      Sets the properties of the axes.
      void setAxisLabelFont​(int style, float size)
      Sets the size of the x and y label font size and style.
      void setAxisXLog​(boolean axisXLog)
      Sets the X Axis format to Log or Linear.
      void setAxisYLog​(boolean axisYLog)
      Sets the Y Axis format to Log or Linear.
      void setBackgroundColor​(java.awt.Color c)
      Set the plot frame background color.
      void setBackgroundColor​(java.lang.String c)
      Set the plot frame background color.
      void setColor​(java.awt.Color c)
      Changes the drawing color for the next objects that will be added to the plot.
      void setColor​(java.awt.Color c, java.awt.Color c2)
      Changes the drawing color for the next objects that will be added to the plot.
      void setColor​(java.lang.String color)  
      void setColor​(java.lang.String c1, java.lang.String c2)
      Sets the drawing color for the next objects that will be added to the plot.
      void setFont​(int style, float size)
      Sets the font size and style for all following drawLabel etc.
      void setFont​(java.awt.Font font)
      Sets the font for all following drawLabel etc.
      void setFormatFlags​(int flags)
      Sets the flags that control the axes format.
      void setFrameSize​(int width, int height)
      Sets the plot frame size in (unscaled) pixels.
      void setFrozen​(boolean frozen)
      Freezes or unfreezes the plot.
      void setImagePlus​(ImagePlus imp)
      Sets the ImagePlus where the plot will be displayed.
      void setJustification​(int justification)
      Sets the justification used by addLabel(), where justification is Plot.LEFT, Plot.CENTER or Plot.RIGHT.
      void setLegend​(java.lang.String labels, int flags)
      Adds a legend.
      void setLimits​(double xMin, double xMax, double yMin, double yMax)
      Sets the x-axis and y-axis range.
      void setLimitsToDefaults​(boolean updateImg)
      Sets the plot range to the initial value determined from minima&maxima or given by setLimits.
      void setLimitsToFit​(boolean updateImg)
      Sets the plot range to encompass all data.
      void setLineWidth​(float lineWidth)
      Changes the line width for the next objects that will be added to the plot.
      void setLineWidth​(int lineWidth)
      Changes the line width for the next objects that will be added to the plot.
      void setLogScaleX()
      Sets log scale in x.
      void setLogScaleY()  
      void setMaxIntervals​(int intervals)
      Sets the maximum number of intervals in a plot.
      void setMinorTickLength​(int minorTickLength)
      Sets the length of the minor tick in pixels.
      void setPlotMaker​(PlotMaker plotMaker)  
      void setPreviousMinMax()
      reverts plot range to previous values and updates the image
      void setScale​(float scale)
      Sets the scale.
      void setSize​(int width, int height)
      Sets the canvas size in unscaled pixels and sets the scale to 1.0.
      void setTickLength​(int tickLength)
      Sets the length of the major tick in pixels.
      void setXLabelFont​(java.awt.Font font)
      Sets the xLabelFont; must not be mull.
      void setXMinorTicks​(boolean xMinorTicks)
      Sets whether to show minor ticks on the x axis (if linear).
      void setXTicks​(boolean xTicks)
      Sets whether to show major ticks at the x axis.
      void setXYLabels​(java.lang.String xLabel, java.lang.String yLabel)
      Sets the labels of the x and y axes.
      void setYLabelFont​(java.awt.Font font)
      Sets the yLabelFont; must not be null.
      void setYMinorTicks​(boolean yMinorTicks)
      Sets whether to show minor ticks on the y axis (if linear).
      void setYTicks​(boolean yTicks)
      Sets whether to show major ticks at the y axis.
      PlotWindow show()
      Displays the plot in a PlotWindow and returns a reference to the PlotWindow.
      static int toShape​(java.lang.String str)  
      void updateImage()
      Draws the plot again, ignored if the plot has not been drawn before or the plot is frozen If the ImagePlus exist, updates it and its calibration.
      void useTemplate​(Plot plot)
      Adjusts the format with another plot as a template, using the current (usually default) flags of this plot.
      void useTemplate​(Plot plot, int templateFlags)
      Adjusts the format with another plot as a template.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LEGEND_BOTTOM_UP

        public static final int LEGEND_BOTTOM_UP
        Legend has its curves in bottom-to-top sequence (otherwise top to bottom)
        See Also:
        Constant Field Values
      • LEGEND_TRANSPARENT

        public static final int LEGEND_TRANSPARENT
        Legend erases background (otherwise transparent)
        See Also:
        Constant Field Values
      • CIRCLE

        public static final int CIRCLE
        Display points using a circle (5 pixels in diameter if line thickness<=1, otherwise 7).
        See Also:
        Constant Field Values
      • BOX

        public static final int BOX
        Display points using a square box-shaped mark.
        See Also:
        Constant Field Values
      • TRIANGLE

        public static final int TRIANGLE
        Display points using an tiangular mark.
        See Also:
        Constant Field Values
      • CROSS

        public static final int CROSS
        Display points using an cross-shaped mark.
        See Also:
        Constant Field Values
      • CONNECTED_CIRCLES

        public static final int CONNECTED_CIRCLES
        Draw black lines between the dots and a circle with the given color at each dot
        See Also:
        Constant Field Values
      • X_NUMBERS

        public static final int X_NUMBERS
        flag for numeric labels of x-axis ticks
        See Also:
        Constant Field Values
      • Y_NUMBERS

        public static final int Y_NUMBERS
        flag for numeric labels of x-axis ticks
        See Also:
        Constant Field Values
      • X_TICKS

        public static final int X_TICKS
        flag for drawing major ticks on linear (non-logarithmic) x axis
        See Also:
        Constant Field Values
      • Y_TICKS

        public static final int Y_TICKS
        flag for drawing major ticks on linear (non-logarithmic) y axis
        See Also:
        Constant Field Values
      • X_GRID

        public static final int X_GRID
        flag for drawing vertical grid lines for x axis
        See Also:
        Constant Field Values
      • Y_GRID

        public static final int Y_GRID
        flag for drawing horizontal grid lines for y axis
        See Also:
        Constant Field Values
      • X_FORCE2GRID

        public static final int X_FORCE2GRID
        flag for forcing frame to coincide with the grid/ticks in x direction (results in unused space)
        See Also:
        Constant Field Values
      • Y_FORCE2GRID

        public static final int Y_FORCE2GRID
        flag for forcing frame to coincide with the grid/ticks in y direction (results in unused space)
        See Also:
        Constant Field Values
      • X_MINOR_TICKS

        public static final int X_MINOR_TICKS
        flag for drawing minor ticks on linear (non-logarithmic) x axis
        See Also:
        Constant Field Values
      • Y_MINOR_TICKS

        public static final int Y_MINOR_TICKS
        flag for drawing minor ticks on linear (non-logarithmic) y axis
        See Also:
        Constant Field Values
      • X_LOG_NUMBERS

        public static final int X_LOG_NUMBERS
        flag for logarithmic x-axis
        See Also:
        Constant Field Values
      • Y_LOG_NUMBERS

        public static final int Y_LOG_NUMBERS
        flag for logarithmic y axis
        See Also:
        Constant Field Values
      • X_LOG_TICKS

        public static final int X_LOG_TICKS
        flag for ticks (major and minor, if space) on logarithmic x axis
        See Also:
        Constant Field Values
      • Y_LOG_TICKS

        public static final int Y_LOG_TICKS
        flag for ticks (major and minor, if space) on logarithmic y axis
        See Also:
        Constant Field Values
      • DEFAULT_FLAGS

        public static final int DEFAULT_FLAGS
        The default flags, will be modified by PlotWindow.noGridLines and PlotWindow.noTicks (see getDefaultFlags)
        See Also:
        Constant Field Values
      • X_RANGE

        public static final int X_RANGE
        Flag for copying from a template: copy x axis range.
        See Also:
        Constant Field Values
      • Y_RANGE

        public static final int Y_RANGE
        Flag for copying from a template: copy y axis range
        See Also:
        Constant Field Values
      • COPY_SIZE

        public static final int COPY_SIZE
        Flag for copying from a template: copy text of axis labels
        See Also:
        Constant Field Values
      • COPY_LABELS

        public static final int COPY_LABELS
        Flag for copying from a template: copy text of axis labels
        See Also:
        Constant Field Values
      • COPY_LEGEND

        public static final int COPY_LEGEND
        Flag for copying from a template: copy legend
        See Also:
        Constant Field Values
      • LEFT_MARGIN

        public static final int LEFT_MARGIN
        Deprecated.
        Not a fixed value any more, use getDrawingFrame() to get the drawing area
        The default margin width left of the plot frame (enough for 5-digit numbers such as unscaled 16-bit
        See Also:
        Constant Field Values
      • RIGHT_MARGIN

        public static final int RIGHT_MARGIN
        Deprecated.
        Not a fixed value any more, use getDrawingFrame() to get the drawing area
        The default margin width right of the plot frame
        See Also:
        Constant Field Values
      • TOP_MARGIN

        public static final int TOP_MARGIN
        Deprecated.
        Not a fixed value any more, use getDrawingFrame() to get the drawing area
        The default margin width above the plot frame
        See Also:
        Constant Field Values
      • BOTTOM_MARGIN

        public static final int BOTTOM_MARGIN
        Deprecated.
        Not a fixed value any more, use getDrawingFrame() to get the drawing area
        The default margin width below the plot frame
        See Also:
        Constant Field Values
      • MIN_FRAMEWIDTH

        public static final int MIN_FRAMEWIDTH
        minimum width of frame area in plot
        See Also:
        Constant Field Values
      • MIN_FRAMEHEIGHT

        public static final int MIN_FRAMEHEIGHT
        minimum width of frame area in plot
        See Also:
        Constant Field Values
      • PROPERTY_KEY

        public static final java.lang.String PROPERTY_KEY
        key in ImagePlus properties to access the plot behind an ImagePlus
        See Also:
        Constant Field Values
    • Constructor Detail

      • Plot

        public Plot​(java.lang.String title,
                    java.lang.String xLabel,
                    java.lang.String yLabel,
                    float[] xValues,
                    float[] yValues)
        Construct a new PlotWindow. Note that the data xValues, yValues passed with the constructor are plotted last, with the settings (color, lineWidth) at the time when 'draw' or 'getProcessor' is called. These data are plotted as a LINE.
        Parameters:
        title - the window title
        xLabel - the x-axis label
        yLabel - the y-axis label
        xValues - the x-coodinates, or null. If null and yValues is not null, integers starting at 0 will be used for x.
        yValues - the y-coodinates, or null for providing no data yet.
      • Plot

        public Plot​(java.lang.String title,
                    java.lang.String xLabel,
                    java.lang.String yLabel,
                    double[] xValues,
                    double[] yValues)
        This version of the constructor accepts double arrays.
      • Plot

        public Plot​(java.lang.String dummy,
                    java.lang.String title,
                    java.lang.String xLabel,
                    java.lang.String yLabel,
                    float[] xValues,
                    float[] yValues)
        This is a constructor that works with JavaScript.
      • Plot

        public Plot​(java.lang.String title,
                    java.lang.String xLabel,
                    java.lang.String yLabel)
        This is a version of the constructor with no intial arrays.
      • Plot

        public Plot​(java.lang.String title,
                    java.lang.String xLabel,
                    java.lang.String yLabel,
                    int flags)
        This is a version of the constructor with no intial arrays.
      • Plot

        public Plot​(java.lang.String title,
                    java.lang.String xLabel,
                    java.lang.String yLabel,
                    float[] xValues,
                    float[] yValues,
                    int flags)
        This version of the constructor has a 'flags' argument for controlling the appearance of ticks, grid, etc.
      • Plot

        public Plot​(java.lang.String title,
                    java.lang.String xLabel,
                    java.lang.String yLabel,
                    double[] xValues,
                    double[] yValues,
                    int flags)
        This version of the constructor accepts double arrays and has a 'flags' argument.
    • Method Detail

      • getTitle

        public java.lang.String getTitle()
        Returns the title of the image showing the plot (if any) or title of the plot
      • setLimits

        public void setLimits​(double xMin,
                              double xMax,
                              double yMin,
                              double yMax)
        Sets the x-axis and y-axis range. Updates the image if existing. Accepts NaN values to indicate auto-range
      • getLimits

        public double[] getLimits()
        Returns the current limits as an array xMin, xMax, yMin, yMax. Note that future versions might return a longer array (e.g. for y2 axis limits)
      • setSize

        public void setSize​(int width,
                            int height)
        Sets the canvas size in unscaled pixels and sets the scale to 1.0. If the scale remains 1.0, this will be the size of the resulting ImageProcessor. When not called, the canvas size is adjusted for the plot frame size specified in Edit>Options>Plots.
      • getSize

        public java.awt.Dimension getSize()
        The size of the plot including borders with axis labels etc., in pixels
      • setFrameSize

        public void setFrameSize​(int width,
                                 int height)
        Sets the plot frame size in (unscaled) pixels. This size does not include the borders with the axis labels. This frame size in pixels divided by the data range defines the image scale. This method does not check for the minimum size MIN_FRAMEWIDTH, MIN_FRAMEHEIGHT. Note that the black frame will have an outer size that is one pixel larger (when plotted with a linewidth of one pixel).
      • getMinimumSize

        public java.awt.Dimension getMinimumSize()
        The minimum plot size including borders, in pixels (at scale=1)
      • useTemplate

        public void useTemplate​(Plot plot)
        Adjusts the format with another plot as a template, using the current (usually default) flags of this plot. Does not modify the properties of individual data sets (marker symbol, color, line thickness...). plot may be null; then the call has no effect.
      • useTemplate

        public void useTemplate​(Plot plot,
                                int templateFlags)
        Adjusts the format with another plot as a template. Flags determine what to copy from the template. Does not modify the properties of individual data sets (marker symbol, color, line thickness...). plot may be null; then the call has no effect.
      • setScale

        public void setScale​(float scale)
        Sets the scale. Everything, including labels, line thicknesses, etc will be scaled by this factor. Should be called before creating the plot.
      • setXYLabels

        public void setXYLabels​(java.lang.String xLabel,
                                java.lang.String yLabel)
        Sets the labels of the x and y axes. Labels may be null. Call updateImage() thereafter to make the change visible (if it is shown already).
      • setMaxIntervals

        public void setMaxIntervals​(int intervals)
        Sets the maximum number of intervals in a plot. Call updateImage() thereafter to make the change visible (if the image is shown already).
      • setTickLength

        public void setTickLength​(int tickLength)
        Sets the length of the major tick in pixels. Call updateImage() thereafter to make the change visible (if the image is shown already).
      • setMinorTickLength

        public void setMinorTickLength​(int minorTickLength)
        Sets the length of the minor tick in pixels.
      • setFormatFlags

        public void setFormatFlags​(int flags)
        Sets the flags that control the axes format. Does not modify the flags for logarithmic axes on/off and the FORCE2GRID flags. Call updateImage() thereafter to make the change visible (if it is shown already).
      • getFlags

        public int getFlags()
        Returns the flags that control the axes
      • setAxisXLog

        public void setAxisXLog​(boolean axisXLog)
        Sets the X Axis format to Log or Linear. Call updateImage() thereafter to make the change visible (if it is shown already).
      • setAxisYLog

        public void setAxisYLog​(boolean axisYLog)
        Sets the Y Axis format to Log or Linear. Call updateImage() thereafter to make the change visible (if it is shown already).
      • setXTicks

        public void setXTicks​(boolean xTicks)
        Sets whether to show major ticks at the x axis. Call updateImage() thereafter to make the change visible (if the image is shown already).
      • setYTicks

        public void setYTicks​(boolean yTicks)
        Sets whether to show major ticks at the y axis. Call updateImage() thereafter to make the change visible (if the image is shown already).
      • setXMinorTicks

        public void setXMinorTicks​(boolean xMinorTicks)
        Sets whether to show minor ticks on the x axis (if linear). Also sets major ticks if true and no grid is set. Call updateImage() thereafter to make the change visible (if the image is shown already).
      • setYMinorTicks

        public void setYMinorTicks​(boolean yMinorTicks)
        Sets whether to show minor ticks on the y axis (if linear). Also sets major ticks if true and no grid is set. Call updateImage() thereafter to make the change visible (if the image is shown already).
      • setAxes

        public void setAxes​(boolean xLog,
                            boolean yLog,
                            boolean xTicks,
                            boolean yTicks,
                            boolean xMinorTicks,
                            boolean yMinorTicks,
                            int tickLenght,
                            int minorTickLenght)
        Sets the properties of the axes. Call updateImage() thereafter to make the change visible (if the image is shown already).
      • setLogScaleX

        public void setLogScaleX()
        Sets log scale in x. Call updateImage() thereafter to make the change visible (if the image is shown already).
      • setLogScaleY

        public void setLogScaleY()
      • getDefaultFlags

        public static int getDefaultFlags()
        The default flags, taking PlotWindow.noGridLines, PlotWindow.noTicks into account
      • addPoints

        public void addPoints​(float[] xValues,
                              float[] yValues,
                              float[] yErrorBars,
                              int shape,
                              java.lang.String label)
        Adds a set of points to the plot or adds a curve if shape is set to LINE.
        Parameters:
        xValues - the x coordinates, or null. If null, integers starting at 0 will be used for x.
        yValues - the y coordinates (must not be null)
        yErrorBars - error bars in y, may be null
        shape - CIRCLE, X, BOX, TRIANGLE, CROSS, DOT, LINE, CONNECTED_CIRCLES
        label - Label for this curve or set of points, used for a legend and for listing the plots
      • addPoints

        public void addPoints​(float[] x,
                              float[] y,
                              int shape)
        Adds a set of points to the plot or adds a curve if shape is set to LINE.
        Parameters:
        x - the x coordinates
        y - the y coordinates
        shape - CIRCLE, X, BOX, TRIANGLE, CROSS, DOT, LINE, CONNECTED_CIRCLES
      • addPoints

        public void addPoints​(double[] x,
                              double[] y,
                              int shape)
        Adds a set of points to the plot using double arrays.
      • addPoints

        public void addPoints​(java.lang.String dummy,
                              float[] x,
                              float[] y,
                              int shape)
        This a version of addPoints that works with JavaScript.
      • add

        public void add​(java.lang.String shape,
                        double[] x,
                        double[] y)
      • toShape

        public static int toShape​(java.lang.String str)
      • addPoints

        public void addPoints​(java.util.ArrayList x,
                              java.util.ArrayList y,
                              int shape)
        Adds a set of points to the plot using double ArrayLists. Must be called before the plot is displayed.
      • addPoints

        public void addPoints​(double[] x,
                              double[] y,
                              double[] errorBars,
                              int shape)
        Adds a set of points to the plot or adds a curve if shape is set to LINE.
        Parameters:
        x - the x-coodinates
        y - the y-coodinates
        errorBars - the vertical error bars, may be null
        shape - CIRCLE, X, BOX, TRIANGLE, CROSS, DOT or LINE
      • addPoints

        public void addPoints​(java.util.ArrayList x,
                              java.util.ArrayList y,
                              java.util.ArrayList z,
                              int shape)
        Adds a set of points to the plot using double ArrayLists. Must be called before the plot is displayed.
      • getDoubleFromArrayList

        public double[] getDoubleFromArrayList​(java.util.ArrayList list)
      • drawVectors

        public void drawVectors​(double[] x1,
                                double[] y1,
                                double[] x2,
                                double[] y2)
        Adds a set of points that will be drawn as ARROWs.
        Parameters:
        x1 - the x-coodinates of the beginning of the arrow
        y1 - the y-coodinates of the beginning of the arrow
        x2 - the x-coodinates of the end of the arrow
        y2 - the y-coodinates of the end of the arrow
      • calculateDistance

        public static double calculateDistance​(int x1,
                                               int y1,
                                               int x2,
                                               int y2)
      • drawVectors

        public void drawVectors​(java.util.ArrayList x1,
                                java.util.ArrayList y1,
                                java.util.ArrayList x2,
                                java.util.ArrayList y2)
        Adds a set of vectors to the plot using double ArrayLists. Does not support logarithmic axes. Must be called before the plot is displayed.
      • addErrorBars

        public void addErrorBars​(float[] errorBars)
        Adds vertical error bars to the last data passed to the plot (via the constructor or addPoints).
      • addErrorBars

        public void addErrorBars​(double[] errorBars)
        Adds vertical error bars to the last data passed to the plot (via the constructor or addPoints).
      • addErrorBars

        public void addErrorBars​(java.lang.String dummy,
                                 float[] errorBars)
        This is a version of addErrorBars that works with JavaScript.
      • addHorizontalErrorBars

        public void addHorizontalErrorBars​(double[] xErrorBars)
        Adds horizontal error bars to the last data passed to the plot (via the constructor or addPoints).
      • addLabel

        public void addLabel​(double x,
                             double y,
                             java.lang.String label)
        Draws text at the specified location, where (0,0) is the upper left corner of the the plot frame and (1,1) is the lower right corner. Uses the justification specified by setJustification().
      • addText

        public void addText​(java.lang.String label,
                            double x,
                            double y)
      • addLegend

        public void addLegend​(java.lang.String labels)
        Adds an automatically positioned legend, where 'labels' is a newline-delimited list of curve or point lables. To modify the legend's style, call 'setFont' and 'setLineWidth' before 'addLegend'.
      • addLegend

        public void addLegend​(java.lang.String labels,
                              java.lang.String options)
      • setLegend

        public void setLegend​(java.lang.String labels,
                              int flags)
        Adds a legend. The legend will be always drawn last (on top of everything). To modify the legend's style, call 'setFont' and 'setLineWidth' before 'addLegend'
        Parameters:
        labels - labels of the points or curves in the sequence of the data added, tab-delimited or linefeed-delimited. The labels of the datasets will be set to these values. If null or not given, the labels set previously (if any) will be used.
        flags - Bitwise or of position (AUTO_POSITION, TOP_LEFT etc.), LEGEND_TRANSPARENT, and LEGEND_BOTTOM_UP if desired. Updates the image (if it is shown already).
      • setJustification

        public void setJustification​(int justification)
        Sets the justification used by addLabel(), where justification is Plot.LEFT, Plot.CENTER or Plot.RIGHT. Default is LEFT.
      • setColor

        public void setColor​(java.awt.Color c)
        Changes the drawing color for the next objects that will be added to the plot. For selecting the color of the curve passed with the constructor, use setColor before draw. The frame and labels are always drawn in black.
      • setColor

        public void setColor​(java.lang.String color)
      • setColor

        public void setColor​(java.awt.Color c,
                             java.awt.Color c2)
        Changes the drawing color for the next objects that will be added to the plot. It also sets secondary color: This is the color of the line for CONNECTED_CIRCLES, and the color for filling open symbols (CIRCLE, BOX, TRIANGLE). Set it to null or use the one-argument call setColor(color) to disable filling. For selecting the color of the curve passed with the constructor, use setColor before draw. The frame and labels are always drawn in black.
      • setColor

        public void setColor​(java.lang.String c1,
                             java.lang.String c2)
        Sets the drawing color for the next objects that will be added to the plot.
      • setBackgroundColor

        public void setBackgroundColor​(java.awt.Color c)
        Set the plot frame background color.
      • setBackgroundColor

        public void setBackgroundColor​(java.lang.String c)
        Set the plot frame background color.
      • setLineWidth

        public void setLineWidth​(int lineWidth)
        Changes the line width for the next objects that will be added to the plot.
      • setLineWidth

        public void setLineWidth​(float lineWidth)
        Changes the line width for the next objects that will be added to the plot.
      • drawLine

        public void drawLine​(double x1,
                             double y1,
                             double x2,
                             double y2)
      • drawNormalizedLine

        public void drawNormalizedLine​(double x1,
                                       double y1,
                                       double x2,
                                       double y2)
        Draws a line using a normalized 0-1, 0-1 coordinate system, with (0,0) at the top left and (1,1) at the lower right corner. This is the same coordinate system used by addLabel(x,y,label).
      • drawDottedLine

        public void drawDottedLine​(double x1,
                                   double y1,
                                   double x2,
                                   double y2,
                                   int step)
      • setFont

        public void setFont​(java.awt.Font font)
        Sets the font for all following drawLabel etc. operations. The currently set font when displaying the plot determines the font of all labels & numbers Call updateImage() thereafter to make the change visible (if the image is shown already).
      • setFont

        public void setFont​(int style,
                            float size)
        Sets the font size and style for all following drawLabel etc. operations. This leaves the font name and style of the previously used fonts unchanged. The currently set font when displaying the plot determines the font of the numbers at the axes. That font also sets the default label font size, which may be overridden by setAxisLabelFontSize or setXLabelFont, setYLabelFont. Styles are defined in the Font class, e.g. Font.PLAIN, Font.BOLD. Set style to -1 to leave the style unchanged. Call updateImage() thereafter to make the change visible (if the image is shown already).
      • setAxisLabelFont

        public void setAxisLabelFont​(int style,
                                     float size)
        Sets the size of the x and y label font size and style. Styles are defined in the Font class, e.g. Font.PLAIN, Font.BOLD. Set style to -1 to leave the style unchanged. Call updateImage() thereafter to make the change visible (if the image is shown already).
      • setXLabelFont

        public void setXLabelFont​(java.awt.Font font)
        Sets the xLabelFont; must not be mull. If this method is not used, the last setFont of setFontSize call before displaying the plot determines the font, or if neither was called, the font size of the Plot Options is used.
      • setYLabelFont

        public void setYLabelFont​(java.awt.Font font)
        Sets the yLabelFont; must not be null.
      • setAntialiasedText

        public void setAntialiasedText​(boolean antialiasedText)
        Determines whether to use antialiased text (default true)
      • changeFont

        public void changeFont​(java.awt.Font font)
        Obsolete; replaced by setFont().
      • getXValues

        public float[] getXValues()
        Get the x coordinates of the data set passed with the constructor (if not null) or otherwise of the data set of the first 'addPoints'. Returns null if neither exists
      • getYValues

        public float[] getYValues()
        Get the y coordinates of the data set passed with the constructor (if not null) or otherwise of the data set of the first 'addPoints'. Returns null if neither exists
      • setLimitsToDefaults

        public void setLimitsToDefaults​(boolean updateImg)
        Sets the plot range to the initial value determined from minima&maxima or given by setLimits. Updates the image if existing and updateImg is true
      • setLimitsToFit

        public void setLimitsToFit​(boolean updateImg)
        Sets the plot range to encompass all data. Updates the image if existing.
      • setPreviousMinMax

        public void setPreviousMinMax()
        reverts plot range to previous values and updates the image
      • getProcessor

        public ImageProcessor getProcessor()
        Draws the plot (if not done before) in an ImageProcessor and returns the ImageProcessor with the plot.
      • getImagePlus

        public ImagePlus getImagePlus()
        Returns the plot as an ImagePlus. If an ImagePlus for this plot already exists, displays the plot in that ImagePlus and returns it.
      • setImagePlus

        public void setImagePlus​(ImagePlus imp)
        Sets the ImagePlus where the plot will be displayed. If the ImagePlus is not known otherwise (e.g. from getImagePlus), this is needed for changes such as zooming in to work correctly. It also sets the calibration of the ImagePlus. The ImagePlus is not displayed or updated. 'imp' may be null to disconnect the plot from its ImagePlus
      • adjustCalibration

        public void adjustCalibration​(Calibration cal)
        Adjusts a Calibration object to fit the current axes. For log axes, the calibration refers to the base-10 logarithm of the value
      • show

        public PlotWindow show()
        Displays the plot in a PlotWindow and returns a reference to the PlotWindow. Note that the PlotWindow might get closed immediately if its 'listValues' and 'autoClose' flags are set
      • draw

        public void draw()
        Draws the plot specified for the first time. Does nothing if the plot has been drawn already. Call getProcessor to retrieve the ImageProcessor with it. Does no action with respect to the ImagePlus (it any)
      • setFrozen

        public void setFrozen​(boolean frozen)
        Freezes or unfreezes the plot. In the frozen state, the plot cannot be resized or updated, and the Plot class does no modifications to the ImageProcessor. Changes are recorded nevertheless and become effective with setFrozen(false).
      • isFrozen

        public boolean isFrozen()
      • updateImage

        public void updateImage()
        Draws the plot again, ignored if the plot has not been drawn before or the plot is frozen If the ImagePlus exist, updates it and its calibration.
      • getDrawingFrame

        public java.awt.Rectangle getDrawingFrame()
        Returns the rectangle where the data are plotted. This rectangle includes the black outline frame at the top and left, but not at the bottom and right (when the frame is plotted with 1 pxl width). The image scale is its width or height in pixels divided by the data range in x or y.
      • makeHighResolution

        public ImagePlus makeHighResolution​(java.lang.String title,
                                            float scale,
                                            boolean antialiasedText,
                                            boolean showIt)
        Creates a new high-resolution plot by scaling it and displays that plot if showIt is true. title may be null, then a default title is used.
      • dispose

        public void dispose()
        Releases the ImageProcessor and ImagePlus associated with the plot. May help garbage collection because some garbage collectors are said to be inefficient with circular references.
      • descaleX

        public double descaleX​(int x)
        Converts pixels to calibrated coordinates. In contrast to the image calibration, also works with log axes and inverted x axes
      • descaleY

        public double descaleY​(int y)
        Converts pixels to calibrated coordinates. In contrast to the image calibration, also works with log axes
      • scaleXtoPxl

        public double scaleXtoPxl​(double x)
        Converts calibrated coordinates to pixel coordinates. In contrast to the image calibration, also works with log x axis and inverted x axis
      • scaleYtoPxl

        public double scaleYtoPxl​(double y)
        Converts calibrated coordinates to pixel coordinates. In contrast to the image calibration, also works with log y axis
      • drawArrow

        public void drawArrow​(int x1,
                              int y1,
                              int x2,
                              int y2,
                              double size)
        Adds an arrow from position 1 to 2 given in pixels; 'size' is the length of the arrowhead WARNING: Use as a public method is not supported any more because it is incompatible with rescaling
      • setPlotMaker

        public void setPlotMaker​(PlotMaker plotMaker)
      • getResultsTable

        public ResultsTable getResultsTable()
        Creates a ResultsTable with the plot data. Returns an empty table if no data.
      • getResultsTable

        public ResultsTable getResultsTable​(boolean writeFirstXColumn)
        Creates a ResultsTable with the data of the plot. Returns an empty table if no data. Does not write the first x column if writeFirstXColumn is false. x columns equal to the first x column are never written, independent of writeFirstXColumn