Module ij
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 PlotProperties, PlotObjects, 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), Norbert Vischer (overlay range arrows, 'R'eset range, filled plots, dynamic plots, boxes and whiskers, superscript), Michael Schmid (axis grid/ticks, resizing/panning/changing range, high-resolution, serialization)
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int AUTO_POSITION
      Legend positions
      static int BAR
      Draw a histogram bar for each point (bars touch each other unless the x axis has categories set via the axis label.
      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_AXIS_STYLE
      Flag for copying from a template: copy axis style
      static int COPY_CONTENTS_STYLE
      Flag for copying from a template: copy contents style
      static int COPY_EXTRA_OBJECTS
      Flag for copying PlotObjects (curves...) from a template if the template has more PlotObjects than the Plot to copy to.
      static int COPY_LABELS
      Flag for copying from a template: copy style & 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 plot size
      static int CROSS
      Display points using an cross-shaped mark.
      static int CUSTOM
      Draw shape using macro code
      static int DEFAULT_FLAGS
      The default axisFlags, will be modified by PlotWindow.noGridLines and PlotWindow.noTicks (see getDefaultFlags)
      static int DIAMOND
      Display points using an diamond-shaped mark.
      static int DOT
      Display points using a single pixel.
      static int FILLED
      Fill area between line plot and x-axis at y=0.
      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 SEPARATED_BAR
      Draw a free-standing bar for each point.
      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 addressing the x axis, for copying from a template: copy/write 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 addressing the y axis, for copying from a template: copy/write y axis range
      static int Y_TICKS
      flag for drawing major ticks on linear (non-logarithmic) y axis
    • Constructor Summary

      Constructors 
      Constructor Description
      Plot​(ImagePlus imp, java.io.InputStream is)
      Constructs a new plot from an InputStream and closes the stream.
      Plot​(java.lang.String title, java.lang.String xLabel, java.lang.String yLabel)
      Constructs a new Plot with the default options.
      Plot​(java.lang.String title, java.lang.String xLabel, java.lang.String yLabel, double[] x, double[] y)
      Deprecated. 
      Plot​(java.lang.String title, java.lang.String xLabel, java.lang.String yLabel, double[] x, double[] y, int flags)
      Deprecated. 
      Plot​(java.lang.String title, java.lang.String xLabel, java.lang.String yLabel, float[] x, float[] y)
      Deprecated. 
      Plot​(java.lang.String title, java.lang.String xLabel, java.lang.String yLabel, float[] xValues, float[] yValues, int flags)
      Deprecated. 
      Plot​(java.lang.String title, java.lang.String xLabel, java.lang.String yLabel, int flags)
      This version of the constructor has a 'flags' argument for controlling whether ticks, grid, etc.
      Plot​(java.lang.String dummy, java.lang.String title, java.lang.String xLabel, java.lang.String yLabel, float[] x, float[] y)
      Deprecated. 
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void add​(java.lang.String type, double[] yvalues)
      Adds a curve, set of points or error bars to this plot, where 'type' is "line", "connected circle", "filled", "bar", "separated bar", "circle", "box", "triangle", "diamond", "cross", "x", "dot", "error bars" or "xerror bars".
      void add​(java.lang.String type, double[] xvalues, double[] yvalues)
      Adds a curve or set of points to this plot, where 'type' is "line", "connected circle", "filled", "bar", "separated bar", "circle", "box", "triangle", "diamond", "cross", "x" or "dot".
      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)  
      void addHistogram​(double[] values)
      Plots a histogram from an array using auto-binning.
      void addHistogram​(double[] values, double binWidth)
      Plots a histogram from an array using the specified bin width.
      void addHistogram​(double[] values, double binWidth, double binCenter)
      Plots a histogram of the value distribution (bin counts) from an array
      void addHorizontalErrorBars​(double[] xErrorBars)
      Adds horizontal error bars to the last data passed to the plot (via the constructor or addPoints).
      void addHorizontalErrorBars​(float[] 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' can be a tab-delimited or newline-delimited list of curve or point labels in the sequence these data were added.
      void addLegend​(java.lang.String labels, java.lang.String options)
      Adds a legend at the position given in 'options', where 'labels' can be tab-delimited or newline-delimited list of curve or point labels in the sequence these data were added.
      int addObjectFromPlot​(Plot plot, int i)
      Add the i-th PlotObject (in the sequence how they were added, including hidden ones) from another plot to this one.
      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)  
      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 errorBars, int shape)
      Adds a set of points to the plot using double ArrayLists.
      void addText​(java.lang.String label, double x, double y)  
      void addToStack()
      Appends the current plot to a virtual stack and resets allPlotObjects for next slice N.
      void adjustCalibration​(Calibration cal)
      Adjusts a Calibration object to fit the current axes.
      void appendToStack()  
      static double calculateDistance​(int x1, int y1, int x2, int y2)  
      void changeFont​(java.awt.Font font)  
      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)
      Deprecated.
      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)
      Draws a line using the coordinate system defined by setLimits().
      void drawLine​(double x1, double y1, double x2, double y2)
      Draws a line using the coordinate system defined by setLimits().
      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 drawShapes​(java.lang.String shapeType, java.util.ArrayList floatCoords)
      Adds a set of 'shapes' such as boxes and whiskers
      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.
      java.awt.Font getCurrentFont()
      Returns the font currently used (e.g.
      float[][] getDataObjectArrays​(int index)
      Get the data of the n-th Plot Object containing xy data in the sequence they were added (Other Plot Objects such as labels, arrows, lines, shapes and hidden PlotObjects are not counted).
      java.lang.String[] getDataObjectDesignations()
      Gets an array with human-readable designations of the PlotObjects containing xy data in the sequence they were added.
      static int getDefaultFlags()
      The default flags, taking PlotWindow.noGridLines, PlotWindow.noTicks into account
      java.awt.Font getDefaultFont()
      Returns the default font for the plot
      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
      java.awt.Font getFont​(char c)
      Gets the font for xLabel ('x'), yLabel('y'), numbers ('f' for 'frame') or the legend ('l').
      ImagePlus getImagePlus()
      Returns the plot as an ImagePlus.
      java.lang.String getLabel​(char c)
      Gets the label String of the xLabel ('x'), yLabel('y') or the legend ('l').
      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)
      int getNumPlotObjects()
      Returns the number of PlotObjects (curves, labels, ...) passed with the constructor or added by 'add' or 'draw' methods.
      int getObjectFlags​(char c)
      Gets the flags of the xLabel ('x'), yLabel('y') or the legend ('l').
      java.lang.String[] getPlotObjectDesignations()
      Gets an array with human-readable designations of the PlotObjects (curves, labels, ...) in the sequence they were added (the object passed with the constructor is first, even though it is plotted last).
      int getPlotObjectIndex​(float[][] values)
      Returns the index of the first plot object with x,y data (points, line) or arrows with all data equal to those given.
      java.lang.String getPlotObjectLabel​(int i)
      Get the label the i-th PlotObject (in the sequence how they were added, including hidden ones).
      java.lang.String getPlotObjectStyle​(int i)
      Get the style of the i-th PlotObject (curve, label, ...) in the sequence they were added (including hidden ones), as String with comma delimiters: Main Color, Secondary Color (or "none"), Line Width [, Symbol shape for XY_DATA] [,hidden] PlotObjects here refers to curves, arrows, labels etc.
      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.
      ResultsTable getResultsTableWithLabels()
      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
      PlotVirtualStack getStack()
      Returns the virtual stack created by addToStack().
      java.lang.String getTitle()
      Returns the title of the image showing the plot (if any) or title of the plot
      java.lang.String[] getTypes()
      Returns an array of the available curve types ("Line", "Bar", "Circle", etc).
      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()  
      void killPlotObjectsSnapshot()
      Deletes the snapshot of the plot contents to make space
      void killPlotPropertiesSnapshot()
      Deletes the snapshot of the plot properties to make space
      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.
      void redrawGrid()  
      void removeNaNs()
      Removes NaNs from the xValues and yValues arrays of all plot objects.
      void replace​(int index, java.lang.String type, double[] xvalues, double[] yvalues)
      Replaces the specified plot object (curve or set of points).
      void restorePlotObjects()
      Restores the plot contents (not including axis formats etc) from the snapshot previously created by savePlotObjects().
      void restorePlotProperties()
      Restores the plot properties (formatting, range etc., not PlotObjects such as data and corresponding curves etc.) from a snapshot previously created by savePlotPlotProperties.
      void savePlotObjects()
      Creates a snapshot of the plot contents (not including axis formats etc), for later undo by restorePlotObjects.
      void savePlotPlotProperties()
      Creates a snapshot of the plot properties (formatting, range etc., not PlotObjects such as data and corresponding curves etc.), for later undo by restorePlotProperties.
      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 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 colors for the next objects that will be added to the plot.
      void setFont​(char c, java.awt.Font font)
      Sets the font for xLabel ('x'), yLabel('y'), numbers ('f' for 'frame') or the legend ('l')
      void setFont​(int style, float size)
      Sets the font size and style for all following addLabel() etc.
      void setFont​(java.awt.Font font)
      Sets the font for all following addLabel() etc.
      void setFontSize​(int size)
      Sets the font size for all following addLabel() 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 setLabel​(int index, java.lang.String label)
      Sets the label for the plot object nuber 'index' in the sequence they were added.
      void setLegend​(java.lang.String labels, int flags)
      Adds a legend.
      void setLimits​(double[] limits)
      Sets the current limits from an array xMin, xMax, yMin, yMax The array may be also longer or shorter, but should not contain NaN values.
      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 setOptions​(java.lang.String options)
      Sets options for the plot.
      void setPlotMaker​(PlotMaker plotMaker)  
      void setPlotObjectLabel​(int i, java.lang.String label)
      Set the label the i-th PlotObject (in the sequence how they were added, including hidden ones) PlotObjects here refers to curves, arrows, labels etc.
      void setPlotObjectStyle​(int i, java.lang.String styleString)  
      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 setStyle​(int index, java.lang.String style)
      Sets the style of the specified PlotObject (curve, label, etc.) from a comma-delimited string ("color1,color2,lineWidth[,symbol][,hidden]"), where "color2" can be "none" and "symbol" and "hidden" are optional.
      void setTickLength​(int tickLength)
      Sets the length of the major tick in pixels.
      void setWindowSize​(int width, int height)
      Sets the plot window size in pixels.
      void setXLabelFont​(java.awt.Font font)
      Sets the xLabelFont; must not be null.
      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.
      byte[] toByteArray()
      Writes this plot into a byte array containing (1) the serialized PlotProperties and (2) the serialized Vector of all 'added' PlotObjects.
      static int toShape​(java.lang.String str)
      Returns the number for a given plot symbol shape, -1 for xError and -2 for yError (all case-insensitive)
      void update()
      Draws the plot again, ignored if the plot has not been drawn before or the plot is frozen.
      void updateImage()
      Draws the plot again, ignored if the plot has not been drawn before or the plot is frozen.
      void useTemplate​(Plot plot)
      Adjusts the format with another plot as a template, using the current (usually default) templateFlags of this plot.
      void useTemplate​(Plot plot, int templateFlags)
      Adjusts the format (style) 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
      • DIAMOND

        public static final int DIAMOND
        Display points using an diamond-shaped mark.
        See Also:
        Constant Field Values
      • FILLED

        public static final int FILLED
        Fill area between line plot and x-axis at y=0.
        See Also:
        Constant Field Values
      • BAR

        public static final int BAR
        Draw a histogram bar for each point (bars touch each other unless the x axis has categories set via the axis label. x values should be sorted (ascending or descending)
        See Also:
        Constant Field Values
      • SEPARATED_BAR

        public static final int SEPARATED_BAR
        Draw a free-standing bar for each point. x values should be equidistant and sorted (ascending or descending)
        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 axisFlags, 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 addressing the x axis, for copying from a template: copy/write x axis range.
        See Also:
        Constant Field Values
      • Y_RANGE

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

        public static final int COPY_SIZE
        Flag for copying from a template: copy plot size
        See Also:
        Constant Field Values
      • COPY_LABELS

        public static final int COPY_LABELS
        Flag for copying from a template: copy style & 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
      • COPY_AXIS_STYLE

        public static final int COPY_AXIS_STYLE
        Flag for copying from a template: copy axis style
        See Also:
        Constant Field Values
      • COPY_CONTENTS_STYLE

        public static final int COPY_CONTENTS_STYLE
        Flag for copying from a template: copy contents style
        See Also:
        Constant Field Values
      • COPY_EXTRA_OBJECTS

        public static final int COPY_EXTRA_OBJECTS
        Flag for copying PlotObjects (curves...) from a template if the template has more PlotObjects than the Plot to copy to.
        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)
        Constructs a new Plot with the default options. Use add(shape,xvalues,yvalues) to add curves.
        Parameters:
        title - the window title
        xLabel - the x-axis label; see setXYLabels for seting categories on an axis via the label
        yLabel - the y-axis label; see setXYLabels for seting categories on an axis via the label
        See Also:
        add(String,double[],double[]), add(String,double[])
      • Plot

        public Plot​(java.lang.String title,
                    java.lang.String xLabel,
                    java.lang.String yLabel,
                    float[] x,
                    float[] y)
        Deprecated.
        Obsolete, replaced by "new Plot(title,xLabel,yLabel); add(shape,x,y);".
      • Plot

        public Plot​(java.lang.String title,
                    java.lang.String xLabel,
                    java.lang.String yLabel,
                    double[] x,
                    double[] y)
        Deprecated.
        Obsolete, replaced by "new Plot(title,xLabel,yLabel); add(shape,x,y);".
      • Plot

        public Plot​(java.lang.String title,
                    java.lang.String xLabel,
                    java.lang.String yLabel,
                    int flags)
        This version of the constructor has a 'flags' argument for controlling whether ticks, grid, etc. are present and whether the axes are logarithmic
      • Plot

        public Plot​(java.lang.String title,
                    java.lang.String xLabel,
                    java.lang.String yLabel,
                    float[] xValues,
                    float[] yValues,
                    int flags)
        Deprecated.
        Obsolete, replaced by "new Plot(title,xLabel,yLabel,flags); add(shape,x,y);".
      • Plot

        public Plot​(java.lang.String title,
                    java.lang.String xLabel,
                    java.lang.String yLabel,
                    double[] x,
                    double[] y,
                    int flags)
        Deprecated.
        Obsolete, replaced by "new Plot(title,xLabel,yLabel,flags); add(shape,x,y);".
      • Plot

        public Plot​(ImagePlus imp,
                    java.io.InputStream is)
             throws java.io.IOException,
                    java.lang.ClassNotFoundException
        Constructs a new plot from an InputStream and closes the stream. If the ImagePlus is non-null, its title and ImageProcessor are used, but the image displayed is not modified.
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • Plot

        public Plot​(java.lang.String dummy,
                    java.lang.String title,
                    java.lang.String xLabel,
                    java.lang.String yLabel,
                    float[] x,
                    float[] y)
        Deprecated.
        Obsolete, replaced by "new Plot(title,xLabel,yLabel); add(shape,x,y);".
    • Method Detail

      • toByteArray

        public byte[] toByteArray()
        Writes this plot into a byte array containing (1) the serialized PlotProperties and (2) the serialized Vector of all 'added' PlotObjects. The plot should have been drawn already. Returns null on error (which should never happen).
      • 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. Saves the new limits as default (so the 'R' field sets the limits to these). 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 ImageJ versions before to 1.52i have returned incorrect values in case of log axes) Note that future versions might return a longer array (e.g. for y2 axis limits)
      • setLimits

        public void setLimits​(double[] limits)
        Sets the current limits from an array xMin, xMax, yMin, yMax The array may be also longer or shorter, but should not contain NaN values. This method should be used after the plot has been displayed. Does not update the plot; use updateImage() thereafter. Does not save the previous limits, i.e., leaves the default limits (for reset via the 'R' field) untouched.
      • setOptions

        public void setOptions​(java.lang.String options)
        Sets options for the plot. Multiple options may be separated by whitespace or commas. Note that whitespace surrounding the '=' characters is not allowed. Currently recognized options are: "addhspace=10 addvspace=5" Increases the left&right or top&bottom margins by the given number of pixels. "xinterval=30 yinterval=90" Sets interval between numbers, major ticks & grid lines (default intervals are used if the custom intervals would be too dense or too sparse) "xdecimals=2 ydecimals=-1" Sets the minimum number of decimals; use negative numbers for scientific notation. "msymbol=' \\u00d7 '" Sets multiplication symbol for scientific notation, here a cross with spaces.
      • 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 size specified by setFrameSize() or setWindowSize(), or otherwise in Edit>Options>Plots.
        See Also:
        setFrameSize(int,int), setWindowSize(int,int)
      • 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. Also sets the scale to 1.0. 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).
        See Also:
        setWindowSize(int,int)
      • setWindowSize

        public void setWindowSize​(int width,
                                  int height)
        Sets the plot window size in pixels.
        See Also:
        setFrameSize(int,int)
      • 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) templateFlags of this plot. plot may be null; then the call has no effect.
      • useTemplate

        public void useTemplate​(Plot plot,
                                int templateFlags)
        Adjusts the format (style) with another plot as a template. Flags determine what to copy from the template; these can be X_RANGE, Y_RANGE, COPY_SIZE, COPY_LABELS, COPY_AXIS_STYLE, COPY_CONTENTS_STYLE (hidden items are ignored), and COPY_LEGEND. 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. Also multiplies the plot size by this value. Used for 'Create high-resolution plot'. Should be called before creating the plot. Note that plots with a scale different from 1.0 must not be shown in a PlotWindow, but only as simple image in a normal ImageWindow.
      • setXYLabels

        public void setXYLabels​(java.lang.String xLabel,
                                java.lang.String yLabel)
        Sets the labels of the x and y axes. 'xLabel', 'yLabel' may be null. If a label has the form {txt1,txt2,txt3}, the corresponding axis will be labeled not by numbers but rather with the texts "txt1", "txt2" ... instead of 0, 1, ... In this special case, there will be no label for the axis on the plot. Call update() 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 update() 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 update() 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 update() 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 update() 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 update() 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 update() 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 update() 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 update() 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 update() 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 update() thereafter to make the change visible (if the image is shown already).
      • setLogScaleX

        public void setLogScaleX()
        Sets log scale in x. Call update() 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
      • add

        public void add​(java.lang.String type,
                        double[] xvalues,
                        double[] yvalues)
        Adds a curve or set of points to this plot, where 'type' is "line", "connected circle", "filled", "bar", "separated bar", "circle", "box", "triangle", "diamond", "cross", "x" or "dot". Run Help>Examples>JavaScript>Graph Types to see examples. If 'type' is in the form "code: ", the macro given is executed to draw the symbol; macro variables 'x' and 'y' are the pixel coordinates of the point, 'xval' and 'yval' are the plot data and 'i' is the index of the data point (starting with 0 for the first point in the array). The drawing including line thickness, font size, etc. be scaled by scale factor 's' (to make high-resolution plots work). Example: "code: setFont('sanserif',12*s,'bold anti');drawString(d2s(yval,1),x-14*s,y-4*s);" writes the y value for each point above the point.
      • replace

        public void replace​(int index,
                            java.lang.String type,
                            double[] xvalues,
                            double[] yvalues)
        Replaces the specified plot object (curve or set of points). Equivalent to add() if there are no plot objects.
      • add

        public void add​(java.lang.String type,
                        double[] yvalues)
        Adds a curve, set of points or error bars to this plot, where 'type' is "line", "connected circle", "filled", "bar", "separated bar", "circle", "box", "triangle", "diamond", "cross", "x", "dot", "error bars" or "xerror bars".
      • 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, DIAMOND, 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, DIAMOND, 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.
      • toShape

        public static int toShape​(java.lang.String str)
        Returns the number for a given plot symbol shape, -1 for xError and -2 for yError (all case-insensitive)
      • 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 - half-lengths of the vertical error bars, may be null
        shape - CIRCLE, X, BOX, TRIANGLE, CROSS, DIAMOND, DOT or LINE
      • addPoints

        public void addPoints​(java.util.ArrayList x,
                              java.util.ArrayList y,
                              java.util.ArrayList errorBars,
                              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
      • drawShapes

        public void drawShapes​(java.lang.String shapeType,
                               java.util.ArrayList floatCoords)
        Adds a set of 'shapes' such as boxes and whiskers
        Parameters:
        shapeType - e.g. "boxes width=20"
        floatCoords - eg[6][3] holding 1 Xval + 5 Yvals for 3 boxes
      • 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).
      • addHorizontalErrorBars

        public void addHorizontalErrorBars​(float[] xErrorBars)
        Adds horizontal error bars to the last data passed to the plot (via the constructor or addPoints).
      • 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(). When called with the same position as the previous addLabel call, the text of that previous call is replaced
      • 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' can be a tab-delimited or newline-delimited list of curve or point labels in the sequence these data were added. Hidden data sets are ignored. If 'labels' is null or empty, the labels of the data set previously (if any) are used. To modify the legend's style, call 'setFont' and 'setLineWidth' before 'addLegend'.
      • addLegend

        public void addLegend​(java.lang.String labels,
                              java.lang.String options)
        Adds a legend at the position given in 'options', where 'labels' can be tab-delimited or newline-delimited list of curve or point labels in the sequence these data were added. Hidden data sets are ignored; no labels (and no delimiters) should be provided for these. Apart from top to bottom and bottom to top (controlled by "bottom-to-top" in the options), the sequence may be altered by preceding numbers followed by double underscores, such as "1__Other Data Set\t0__First Data Set" (the number and double underscore won't be displayed). When this possibility is used, only items with double underscores will be shown in the legend (preceding double underscores without a number make the item appear in the legend without altering the sequence). If 'labels' is null or empty, the labels of the data set previously (if any) are used. To modify the legend's style, call 'setFont' and 'setLineWidth' before 'addLegend'.
      • 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 were 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. Hidden data sets are ignored; no labels (and no delimiters) should be provided for these. Apart from top to bottom and bottom to top (controlled by the LEGEND_BOTTOM_UP flag), the sequence may be altered by preceding numbers followed by double underscores, such as "1__Other Data Set\t0__First Data Set" (the number and double underscore won't be displayed). When this possibility is used, only items with double underscores will be shown in the legend (preceding double underscores without a number make the item appear in the legend without altering the sequence).
        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).
      • setLabel

        public void setLabel​(int index,
                             java.lang.String label)
        Sets the label for the plot object nuber 'index' in the sequence they were added. With index=-1, sets the label for the last object added. For x/y data, the label is used for the legend and as header in getResultsTableWithLabels. For Text/Label objects, it affects the label shown (but the plot is not redisplayed).
      • removeNaNs

        public void removeNaNs()
        Removes NaNs from the xValues and yValues arrays of all plot objects.
      • getTypes

        public java.lang.String[] getTypes()
        Returns an array of the available curve types ("Line", "Bar", "Circle", etc).
      • 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 colors 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. After all objects have been added, set the line width to the width desired for the frame around the plot (max. 3)
      • drawLine

        public void drawLine​(double x1,
                             double y1,
                             double x2,
                             double y2)
        Draws a line using the coordinate system defined by setLimits().
      • 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)
        Draws a line using the coordinate system defined by setLimits().
      • setFontSize

        public void setFontSize​(int size)
        Sets the font size for all following addLabel() etc. operations. The currently set font when displaying the plot determines the font of all labels & numbers. After the plot has been shown, sets the font for the numbers and the legend (if present). If the plot is hown already, call update() thereafter to make the change visible.
      • setFont

        public void setFont​(java.awt.Font font)
        Sets the font for all following addLabel() etc. operations. The currently set font when displaying the plot determines the font of all labels & numbers. After the plot has been shown, sets the font for the numbers and the legend (if present); use setFont(char, Font) to set these fonts individually. If the plot is hown already, call update() thereafter to make the change visible.
      • setFont

        public void setFont​(int style,
                            float size)
        Sets the font size and style for all following addLabel() 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. After the plot has been shown, sets the font for the numbers and the legend (if present); use setFont(char, Font) to set these fonts individually. Styles are defined in the Font class, e.g. Font.PLAIN, Font.BOLD. Set style to -1 to leave the style unchanged. Call update() thereafter to make the change visible (if the image is shown already).
      • setAxisLabelFont

        public void setAxisLabelFont​(int style,
                                     float size)
        Sets 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 update() 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 null. 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)
      • getCurrentFont

        public java.awt.Font getCurrentFont()
        Returns the font currently used (e.g. for the next 'addLabel')
      • getDefaultFont

        public java.awt.Font getDefaultFont()
        Returns the default font for the plot
      • getFont

        public java.awt.Font getFont​(char c)
        Gets the font for xLabel ('x'), yLabel('y'), numbers ('f' for 'frame') or the legend ('l'). Returns null if the given PlotObject does not exist or its font is null
      • setFont

        public void setFont​(char c,
                            java.awt.Font font)
        Sets the font for xLabel ('x'), yLabel('y'), numbers ('f' for 'frame') or the legend ('l')
      • getLabel

        public java.lang.String getLabel​(char c)
        Gets the label String of the xLabel ('x'), yLabel('y') or the legend ('l'). Returns null if the given PlotObject does not exist or its label is null
      • getObjectFlags

        public int getObjectFlags​(char c)
        Gets the flags of the xLabel ('x'), yLabel('y') or the legend ('l'). Returns -1 if the given PlotObject does not exist
      • 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
      • getDataObjectArrays

        public float[][] getDataObjectArrays​(int index)
        Get the data of the n-th Plot Object containing xy data in the sequence they were added (Other Plot Objects such as labels, arrows, lines, shapes and hidden PlotObjects are not counted). The array returned has elements [0] x data, [1] y data, [2] x error bars, [3] y error bars. If no error bars are given, the corresponding arrays are null. Returns null if there is no Plot Object with xy data with this index.
        See Also:
        getDataObjectDesignations()
      • getPlotObjectDesignations

        public java.lang.String[] getPlotObjectDesignations()
        Gets an array with human-readable designations of the PlotObjects (curves, labels, ...) in the sequence they were added (the object passed with the constructor is first, even though it is plotted last). Hidden PlotObjects are included.
      • getDataObjectDesignations

        public java.lang.String[] getDataObjectDesignations()
        Gets an array with human-readable designations of the PlotObjects containing xy data in the sequence they were added. Other Plot Objects such as labels, arrows, lines, shapes and hidden PlotObjects are not counted. (the object passed with the constructor is first, even though it is plotted last).
      • getNumPlotObjects

        public int getNumPlotObjects()
        Returns the number of PlotObjects (curves, labels, ...) passed with the constructor or added by 'add' or 'draw' methods. Legend, frame and axes (though internally PlotObjects) are not included
      • addObjectFromPlot

        public int addObjectFromPlot​(Plot plot,
                                     int i)
        Add the i-th PlotObject (in the sequence how they were added, including hidden ones) from another plot to this one. PlotObjects here refers to curves, arrows, labels etc. (not legend, axes and frame, though implemented as PlotObjects) Use 'update' to update the plot thereafter.
        Returns:
        Index of the plotObject added in the sequence they were added
      • getPlotObjectStyle

        public java.lang.String getPlotObjectStyle​(int i)
        Get the style of the i-th PlotObject (curve, label, ...) in the sequence they were added (including hidden ones), as String with comma delimiters: Main Color, Secondary Color (or "none"), Line Width [, Symbol shape for XY_DATA] [,hidden] PlotObjects here refers to curves, arrows, labels etc. (not legend, exes and frame, though implemented as PlotObjects)
      • getPlotObjectLabel

        public java.lang.String getPlotObjectLabel​(int i)
        Get the label the i-th PlotObject (in the sequence how they were added, including hidden ones). Returns null if no label. PlotObjects here refers to curves, arrows, labels etc. (not legend, exes and frame, though implemented as PlotObjects)
      • setPlotObjectLabel

        public void setPlotObjectLabel​(int i,
                                       java.lang.String label)
        Set the label the i-th PlotObject (in the sequence how they were added, including hidden ones) PlotObjects here refers to curves, arrows, labels etc. (not legend, exes and frame, though implemented as PlotObjects)
      • setStyle

        public void setStyle​(int index,
                             java.lang.String style)
        Sets the style of the specified PlotObject (curve, label, etc.) from a comma-delimited string ("color1,color2,lineWidth[,symbol][,hidden]"), where "color2" can be "none" and "symbol" and "hidden" are optional. PlotObjects here refers to curves, arrows, labels etc. (not legend, exes and frame, though implemented as PlotObjects)
      • setPlotObjectStyle

        public void setPlotObjectStyle​(int i,
                                       java.lang.String styleString)
      • getPlotObjectIndex

        public int getPlotObjectIndex​(float[][] values)
        Returns the index of the first plot object with x,y data (points, line) or arrows with all data equal to those given. Returns or -1 is no such plot object exists. The array 'values' should contain the x, y, x error bar, yerror bar data. The 'values' array may have any size; only the data given are compared (e.g. for an array with length 2, there is no check for erro bars). Used when adding data from a table not to suggest the same data twice.
      • savePlotObjects

        public void savePlotObjects()
        Creates a snapshot of the plot contents (not including axis formats etc), for later undo by restorePlotObjects. See also killPlotObjectsSnapshot
      • restorePlotObjects

        public void restorePlotObjects()
        Restores the plot contents (not including axis formats etc) from the snapshot previously created by savePlotObjects(). See also killPlotObjectsSnapshot Use 'update' to update the plot thereafter.
      • killPlotObjectsSnapshot

        public void killPlotObjectsSnapshot()
        Deletes the snapshot of the plot contents to make space
      • savePlotPlotProperties

        public void savePlotPlotProperties()
        Creates a snapshot of the plot properties (formatting, range etc., not PlotObjects such as data and corresponding curves etc.), for later undo by restorePlotProperties. See also killPlotPropertiesSnapshot
      • restorePlotProperties

        public void restorePlotProperties()
        Restores the plot properties (formatting, range etc., not PlotObjects such as data and corresponding curves etc.) from a snapshot previously created by savePlotPlotProperties. See also killPlotPropertiesSnapshot. Use 'update' to update the plot thereafter.
      • killPlotPropertiesSnapshot

        public void killPlotPropertiesSnapshot()
        Deletes the snapshot of the plot properties to make space
      • 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 and updateImg is true.
      • 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 unless its ImageProcessor is no that of the current Plot (then it gets this ImageProcessor). Does nothing if imp is unchanged and has the ImageProcessor of this plot. 'imp' may be null to disconnect the plot from its ImagePlus. Does nothing for Plot Stacks.
      • 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. Plot stacks are shown in a StackWindow, not in a PlotWindow; in this case the return value is null (use getImagePlus().getWindow() instead). Also returns null in BatchMode. Note that the PlotWindow might get closed immediately if its 'listValues' and 'autoClose' flags are set.
        See Also:
        update()
      • addToStack

        public void addToStack()
        Appends the current plot to a virtual stack and resets allPlotObjects for next slice N. Vischer
      • appendToStack

        public void appendToStack()
      • getStack

        public PlotVirtualStack getStack()
        Returns the virtual stack created by addToStack().
      • 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 (if 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()
      • update

        public void update()
        Draws the plot again, ignored if the plot has not been drawn before or the plot is frozen.
      • 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
      • redrawGrid

        public void redrawGrid()
      • drawArrow

        @Deprecated
        public void drawArrow​(int x1,
                              int y1,
                              int x2,
                              int y2,
                              double size)
        Deprecated.
        Use as a public method is not supported any more because it is incompatible with rescaling
        Adds an arrow from position 1 to 2 given in pixels; 'size' is the length of the arrowhead
      • 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 null if no data. Does not write the first x column if writeFirstXColumn is false. When all columns are the same length, x columns equal to the first x column are not written, independent of writeFirstXColumn. Column headings are "X", "Y", "X1", "Y1", etc, irrespective of any labels of the data sets
      • getResultsTableWithLabels

        public ResultsTable getResultsTableWithLabels()
        Creates a ResultsTable with the data of the plot. Returns null if no data. When all columns are the same length, x columns equal to the first x column are not written, independent of writeFirstXColumn. When the data sets have labels, they are used for column headings
      • addPoints

        public void addPoints​(java.lang.String dummy,
                              float[] x,
                              float[] y,
                              int shape)
      • addHistogram

        public void addHistogram​(double[] values)
        Plots a histogram from an array using auto-binning.
        Parameters:
        values - array containing the population N.Vischer
      • addHistogram

        public void addHistogram​(double[] values,
                                 double binWidth)
        Plots a histogram from an array using the specified bin width.
        Parameters:
        values - array containing the population
        binWidth - set zero for auto-binning N.Vischer
      • addHistogram

        public void addHistogram​(double[] values,
                                 double binWidth,
                                 double binCenter)
        Plots a histogram of the value distribution (bin counts) from an array
        Parameters:
        values - array containing the values for the population
        binWidth - set zero for auto-binning
        binCenter - any x value can be the center of a bin N.Vischer
      • addErrorBars

        public void addErrorBars​(java.lang.String dummy,
                                 float[] errorBars)
      • changeFont

        public void changeFont​(java.awt.Font font)