Package ij.gui

Class Plot

java.lang.Object
ij.gui.Plot
All Implemented Interfaces:
Cloneable

public class Plot extends Object implements 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 final int
    Legend positions
    static final int
    Legend positions
    static final int
    Deprecated.
    Not a fixed value any more, use getDrawingFrame() to get the drawing area
    static final int
    Legend positions
    static final int
    Display points using a square box-shaped mark.
    static final int
    Text justification.
    static final int
    Display points using a circle (5 pixels in diameter if line thickness<=1, otherwise 7).
    static final int
    Draw black lines between the dots and a circle with the given color at each dot
    static final int
    Flag for copying from a template: copy text of axis labels
    static final int
    Flag for copying from a template: copy legend
    static final int
    Flag for copying from a template: copy text of axis labels
    static final int
    Display points using an cross-shaped mark.
    static final int
    The default flags, will be modified by PlotWindow.noGridLines and PlotWindow.noTicks (see getDefaultFlags)
    static final int
    Display points using a single pixel.
    static final int
    Text justification.
    static final int
    Deprecated.
    Not a fixed value any more, use getDrawingFrame() to get the drawing area
    static final int
    Legend has its curves in bottom-to-top sequence (otherwise top to bottom)
    static final int
    Legend erases background (otherwise transparent)
    static final int
    Connect points with solid lines.
    static final int
    minimum width of frame area in plot
    static final int
    minimum width of frame area in plot
    static final String
    key in ImagePlus properties to access the plot behind an ImagePlus
    static final int
    Text justification.
    static final int
    Deprecated.
    Not a fixed value any more, use getDrawingFrame() to get the drawing area
    static final int
    Legend positions
    static final int
    Deprecated.
    Not a fixed value any more, use getDrawingFrame() to get the drawing area
    static final int
    Legend positions
    static final int
    Display points using an tiangular mark.
    static final int
    Display points using an X-shaped mark.
    static final int
    flag for forcing frame to coincide with the grid/ticks in x direction (results in unused space)
    static final int
    flag for drawing vertical grid lines for x axis
    static final int
    flag for logarithmic x-axis
    static final int
    flag for ticks (major and minor, if space) on logarithmic x axis
    static final int
    flag for drawing minor ticks on linear (non-logarithmic) x axis
    static final int
    flag for numeric labels of x-axis ticks
    static final int
    Flag for copying from a template: copy x axis range.
    static final int
    flag for drawing major ticks on linear (non-logarithmic) x axis
    static final int
    flag for forcing frame to coincide with the grid/ticks in y direction (results in unused space)
    static final int
    flag for drawing horizontal grid lines for y axis
    static final int
    flag for logarithmic y axis
    static final int
    flag for ticks (major and minor, if space) on logarithmic y axis
    static final int
    flag for drawing minor ticks on linear (non-logarithmic) y axis
    static final int
    flag for numeric labels of x-axis ticks
    static final int
    Flag for copying from a template: copy y axis range
    static final int
    flag for drawing major ticks on linear (non-logarithmic) y axis
  • Constructor Summary

    Constructors
    Constructor
    Description
    Plot(String title, String xLabel, String yLabel)
    This is a version of the constructor with no intial arrays.
    Plot(String title, String xLabel, String yLabel, double[] xValues, double[] yValues)
    This version of the constructor accepts double arrays.
    Plot(String title, String xLabel, String yLabel, double[] xValues, double[] yValues, int flags)
    This version of the constructor accepts double arrays and has a 'flags' argument.
    Plot(String title, String xLabel, String yLabel, float[] xValues, float[] yValues)
    Construct a new PlotWindow.
    Plot(String title, String xLabel, 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(String title, String xLabel, String yLabel, int flags)
    This is a version of the constructor with no intial arrays.
    Plot(String dummy, String title, String xLabel, String yLabel, float[] xValues, float[] yValues)
    This is a constructor that works with JavaScript.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(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(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, 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(String labels)
    Adds an automatically positioned legend, where 'labels' is a newline-delimited list of curve or point lables.
    void
    addLegend(String labels, 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, 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(String dummy, float[] x, float[] y, int shape)
    This a version of addPoints that works with JavaScript.
    void
    addPoints(ArrayList x, ArrayList y, int shape)
    Adds a set of points to the plot using double ArrayLists.
    void
    addPoints(ArrayList x, ArrayList y, ArrayList z, int shape)
    Adds a set of points to the plot using double ArrayLists.
    void
    addText(String label, double x, double y)
     
    void
    Adjusts a Calibration object to fit the current axes.
    static double
    calculateDistance(int x1, int y1, int x2, int y2)
     
    void
    Obsolete; replaced by setFont().
    double
    descaleX(int x)
    Converts pixels to calibrated coordinates.
    double
    descaleY(int y)
    Converts pixels to calibrated coordinates.
    void
    Releases the ImageProcessor and ImagePlus associated with the plot.
    void
    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
    Adds a set of vectors to the plot using double ArrayLists.
    static int
    The default flags, taking PlotWindow.noGridLines, PlotWindow.noTicks into account
    double[]
     
    Returns the rectangle where the data are plotted.
    int
    Returns the flags that control the axes
    Returns the plot as an ImagePlus.
    double[]
    Returns the current limits as an array xMin, xMax, yMin, yMax.
    The minimum plot size including borders, in pixels (at scale=1)
    Draws the plot (if not done before) in an ImageProcessor and returns the ImageProcessor with the plot.
    Creates a ResultsTable with the plot data.
    getResultsTable(boolean writeFirstXColumn)
    Creates a ResultsTable with the data of the plot.
    The size of the plot including borders with axis labels etc., in pixels
    Returns the title of the image showing the plot (if any) or title of the plot
    float[]
    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[]
    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
     
    makeHighResolution(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
    Set the plot frame background color.
    void
    Set the plot frame background color.
    void
    Changes the drawing color for the next objects that will be added to the plot.
    void
    Changes the drawing color for the next objects that will be added to the plot.
    void
     
    void
    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(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
    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(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
    Sets log scale in x.
    void
     
    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
     
    void
    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
    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(String xLabel, String yLabel)
    Sets the labels of the x and y axes.
    void
    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.
    Displays the plot in a PlotWindow and returns a reference to the PlotWindow.
    static int
     
    void
    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
    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 Details

    • LEFT

      public static final int LEFT
      Text justification.
      See Also:
    • CENTER

      public static final int CENTER
      Text justification.
      See Also:
    • TOP_LEFT

      public static final int TOP_LEFT
      Legend positions
      See Also:
    • TOP_RIGHT

      public static final int TOP_RIGHT
      Legend positions
      See Also:
    • BOTTOM_LEFT

      public static final int BOTTOM_LEFT
      Legend positions
      See Also:
    • BOTTOM_RIGHT

      public static final int BOTTOM_RIGHT
      Legend positions
      See Also:
    • AUTO_POSITION

      public static final int AUTO_POSITION
      Legend positions
      See Also:
    • 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:
    • LEGEND_TRANSPARENT

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

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

      public static final int X
      Display points using an X-shaped mark.
      See Also:
    • BOX

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

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

      public static final int CROSS
      Display points using an cross-shaped mark.
      See Also:
    • DOT

      public static final int DOT
      Display points using a single pixel.
      See Also:
    • LINE

      public static final int LINE
      Connect points with solid lines.
      See Also:
    • 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:
    • X_NUMBERS

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

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

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

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

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

      public static final int Y_GRID
      flag for drawing horizontal grid lines for y axis
      See Also:
    • 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:
    • 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:
    • X_MINOR_TICKS

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

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

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

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

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

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

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

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

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

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

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

      public static final int COPY_LEGEND
      Flag for copying from a template: copy legend
      See Also:
    • 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:
    • 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:
    • 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:
    • 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:
    • MIN_FRAMEWIDTH

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

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

      public static final String PROPERTY_KEY
      key in ImagePlus properties to access the plot behind an ImagePlus
      See Also:
  • Constructor Details

    • Plot

      public Plot(String title, String xLabel, 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(String title, String xLabel, String yLabel, double[] xValues, double[] yValues)
      This version of the constructor accepts double arrays.
    • Plot

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

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

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

      public Plot(String title, String xLabel, 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(String title, String xLabel, String yLabel, double[] xValues, double[] yValues, int flags)
      This version of the constructor accepts double arrays and has a 'flags' argument.
  • Method Details

    • getTitle

      public 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 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 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(String xLabel, 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, 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(String dummy, float[] x, float[] y, int shape)
      This a version of addPoints that works with JavaScript.
    • add

      public void add(String shape, double[] x, double[] y)
    • toShape

      public static int toShape(String str)
    • addPoints

      public void addPoints(ArrayList x, 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(ArrayList x, ArrayList y, 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(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(ArrayList x1, ArrayList y1, ArrayList x2, 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(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, 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(String label, double x, double y)
    • addLegend

      public void addLegend(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(String labels, String options)
    • setLegend

      public void setLegend(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(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(String color)
    • setColor

      public void setColor(Color c, 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(String c1, String c2)
      Sets the drawing color for the next objects that will be added to the plot.
    • setBackgroundColor

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

      public void setBackgroundColor(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(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(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(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(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 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(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