Package ij.gui
Class Plot
java.lang.Object
ij.gui.Plot
- All Implemented Interfaces:
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
FieldsModifier and TypeFieldDescriptionstatic final int
Legend positionsstatic final int
Legend positionsstatic final int
Deprecated.Not a fixed value any more, use getDrawingFrame() to get the drawing areastatic final int
Legend positionsstatic 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 dotstatic final int
Flag for copying from a template: copy text of axis labelsstatic final int
Flag for copying from a template: copy legendstatic final int
Flag for copying from a template: copy text of axis labelsstatic 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 areastatic 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 plotstatic final int
minimum width of frame area in plotstatic final String
key in ImagePlus properties to access the plot behind an ImagePlusstatic final int
Text justification.static final int
Deprecated.Not a fixed value any more, use getDrawingFrame() to get the drawing areastatic final int
Legend positionsstatic final int
Deprecated.Not a fixed value any more, use getDrawingFrame() to get the drawing areastatic final int
Legend positionsstatic 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 axisstatic final int
flag for logarithmic x-axisstatic final int
flag for ticks (major and minor, if space) on logarithmic x axisstatic final int
flag for drawing minor ticks on linear (non-logarithmic) x axisstatic final int
flag for numeric labels of x-axis ticksstatic 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 axisstatic 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 axisstatic final int
flag for logarithmic y axisstatic final int
flag for ticks (major and minor, if space) on logarithmic y axisstatic final int
flag for drawing minor ticks on linear (non-logarithmic) y axisstatic final int
flag for numeric labels of x-axis ticksstatic final int
Flag for copying from a template: copy y axis rangestatic final int
flag for drawing major ticks on linear (non-logarithmic) y axis -
Constructor Summary
ConstructorsConstructorDescriptionThis is a version of the constructor with no intial arrays.This version of the constructor accepts double arrays.This version of the constructor accepts double arrays and has a 'flags' argument.Construct a new PlotWindow.This version of the constructor has a 'flags' argument for controlling the appearance of ticks, grid, etc.This is a version of the constructor with no intial arrays.This is a constructor that works with JavaScript. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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
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
Adds an automatically positioned legend, where 'labels' is a newline-delimited list of curve or point lables.void
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
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
This a version of addPoints that works with JavaScript.void
Adds a set of points to the plot using double ArrayLists.void
Adds a set of points to the plot using double ArrayLists.void
void
Adjusts a Calibration object to fit the current axes.static double
calculateDistance
(int x1, int y1, int x2, int y2) void
changeFont
(Font font) Obsolete; replaced by setFont().double
descaleX
(int x) Converts pixels to calibrated coordinates.double
descaleY
(int y) Converts pixels to calibrated coordinates.void
dispose()
Releases the ImageProcessor and ImagePlus associated with the plot.void
draw()
Draws the plot specified for the first time.void
drawArrow
(int x1, int y1, int x2, int y2, double size) Adds an arrow from position 1 to 2 given in pixels; 'size' is the length of the arrowhead WARNING: Use as a public method is not supported any more because it is incompatible with rescalingvoid
drawDottedLine
(double x1, double y1, double x2, double y2, int step) void
drawLine
(double x1, double y1, double x2, double y2) void
drawNormalizedLine
(double x1, double y1, double x2, double y2) Draws a line using a normalized 0-1, 0-1 coordinate system, with (0,0) at the top left and (1,1) at the lower right corner.void
drawVectors
(double[] x1, double[] y1, double[] x2, double[] y2) Adds a set of points that will be drawn as ARROWs.void
drawVectors
(ArrayList x1, ArrayList y1, ArrayList x2, ArrayList y2) Adds a set of vectors to the plot using double ArrayLists.static int
The default flags, taking PlotWindow.noGridLines, PlotWindow.noTicks into accountdouble[]
Returns the rectangle where the data are plotted.int
getFlags()
Returns the flags that control the axesReturns 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.getSize()
The size of the plot including borders with axis labels etc., in pixelsgetTitle()
Returns the title of the image showing the plot (if any) or title of the plotfloat[]
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
isFrozen()
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
Sets the font for all following drawLabel etc.void
setFormatFlags
(int flags) Sets the flags that control the axes format.void
setFrameSize
(int width, int height) Sets the plot frame size in (unscaled) pixels.void
setFrozen
(boolean frozen) Freezes or unfreezes the plot.void
setImagePlus
(ImagePlus imp) Sets the ImagePlus where the plot will be displayed.void
setJustification
(int justification) Sets the justification used by addLabel(), wherejustification
is Plot.LEFT, Plot.CENTER or Plot.RIGHT.void
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
setPlotMaker
(PlotMaker plotMaker) void
reverts plot range to previous values and updates the imagevoid
setScale
(float scale) Sets the scale.void
setSize
(int width, int height) Sets the canvas size in unscaled pixels and sets the scale to 1.0.void
setTickLength
(int tickLength) Sets the length of the major tick in pixels.void
setXLabelFont
(Font font) Sets the xLabelFont; must not be mull.void
setXMinorTicks
(boolean xMinorTicks) Sets whether to show minor ticks on the x axis (if linear).void
setXTicks
(boolean xTicks) Sets whether to show major ticks at the x axis.void
setXYLabels
(String xLabel, String yLabel) Sets the labels of the x and y axes.void
setYLabelFont
(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.show()
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
useTemplate
(Plot plot) Adjusts the format with another plot as a template, using the current (usually default) flags of this plot.void
useTemplate
(Plot plot, int templateFlags) Adjusts the format with another plot as a template.
-
Field Details
-
LEFT
public static final int LEFTText justification.- See Also:
-
CENTER
public static final int CENTERText justification.- See Also:
-
RIGHT
public static final int RIGHTText justification.- See Also:
-
TOP_LEFT
public static final int TOP_LEFTLegend positions- See Also:
-
TOP_RIGHT
public static final int TOP_RIGHTLegend positions- See Also:
-
BOTTOM_LEFT
public static final int BOTTOM_LEFTLegend positions- See Also:
-
BOTTOM_RIGHT
public static final int BOTTOM_RIGHTLegend positions- See Also:
-
AUTO_POSITION
public static final int AUTO_POSITIONLegend positions- See Also:
-
LEGEND_BOTTOM_UP
public static final int LEGEND_BOTTOM_UPLegend has its curves in bottom-to-top sequence (otherwise top to bottom)- See Also:
-
LEGEND_TRANSPARENT
public static final int LEGEND_TRANSPARENTLegend erases background (otherwise transparent)- See Also:
-
CIRCLE
public static final int CIRCLEDisplay points using a circle (5 pixels in diameter if line thickness<=1, otherwise 7).- See Also:
-
X
public static final int XDisplay points using an X-shaped mark.- See Also:
-
BOX
public static final int BOXDisplay points using a square box-shaped mark.- See Also:
-
TRIANGLE
public static final int TRIANGLEDisplay points using an tiangular mark.- See Also:
-
CROSS
public static final int CROSSDisplay points using an cross-shaped mark.- See Also:
-
DOT
public static final int DOTDisplay points using a single pixel.- See Also:
-
LINE
public static final int LINEConnect points with solid lines.- See Also:
-
CONNECTED_CIRCLES
public static final int CONNECTED_CIRCLESDraw black lines between the dots and a circle with the given color at each dot- See Also:
-
X_NUMBERS
public static final int X_NUMBERSflag for numeric labels of x-axis ticks- See Also:
-
Y_NUMBERS
public static final int Y_NUMBERSflag for numeric labels of x-axis ticks- See Also:
-
X_TICKS
public static final int X_TICKSflag for drawing major ticks on linear (non-logarithmic) x axis- See Also:
-
Y_TICKS
public static final int Y_TICKSflag for drawing major ticks on linear (non-logarithmic) y axis- See Also:
-
X_GRID
public static final int X_GRIDflag for drawing vertical grid lines for x axis- See Also:
-
Y_GRID
public static final int Y_GRIDflag for drawing horizontal grid lines for y axis- See Also:
-
X_FORCE2GRID
public static final int X_FORCE2GRIDflag 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_FORCE2GRIDflag 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_TICKSflag for drawing minor ticks on linear (non-logarithmic) x axis- See Also:
-
Y_MINOR_TICKS
public static final int Y_MINOR_TICKSflag for drawing minor ticks on linear (non-logarithmic) y axis- See Also:
-
X_LOG_NUMBERS
public static final int X_LOG_NUMBERSflag for logarithmic x-axis- See Also:
-
Y_LOG_NUMBERS
public static final int Y_LOG_NUMBERSflag for logarithmic y axis- See Also:
-
X_LOG_TICKS
public static final int X_LOG_TICKSflag for ticks (major and minor, if space) on logarithmic x axis- See Also:
-
Y_LOG_TICKS
public static final int Y_LOG_TICKSflag for ticks (major and minor, if space) on logarithmic y axis- See Also:
-
DEFAULT_FLAGS
public static final int DEFAULT_FLAGSThe default flags, will be modified by PlotWindow.noGridLines and PlotWindow.noTicks (see getDefaultFlags)- See Also:
-
X_RANGE
public static final int X_RANGEFlag for copying from a template: copy x axis range.- See Also:
-
Y_RANGE
public static final int Y_RANGEFlag for copying from a template: copy y axis range- See Also:
-
COPY_SIZE
public static final int COPY_SIZEFlag for copying from a template: copy text of axis labels- See Also:
-
COPY_LABELS
public static final int COPY_LABELSFlag for copying from a template: copy text of axis labels- See Also:
-
COPY_LEGEND
public static final int COPY_LEGENDFlag for copying from a template: copy legend- See Also:
-
LEFT_MARGIN
public static final int LEFT_MARGINDeprecated.Not a fixed value any more, use getDrawingFrame() to get the drawing areaThe 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_MARGINDeprecated.Not a fixed value any more, use getDrawingFrame() to get the drawing areaThe default margin width right of the plot frame- See Also:
-
TOP_MARGIN
public static final int TOP_MARGINDeprecated.Not a fixed value any more, use getDrawingFrame() to get the drawing areaThe default margin width above the plot frame- See Also:
-
BOTTOM_MARGIN
public static final int BOTTOM_MARGINDeprecated.Not a fixed value any more, use getDrawingFrame() to get the drawing areaThe default margin width below the plot frame- See Also:
-
MIN_FRAMEWIDTH
public static final int MIN_FRAMEWIDTHminimum width of frame area in plot- See Also:
-
MIN_FRAMEHEIGHT
public static final int MIN_FRAMEHEIGHTminimum width of frame area in plot- See Also:
-
PROPERTY_KEY
key in ImagePlus properties to access the plot behind an ImagePlus- See Also:
-
-
Constructor Details
-
Plot
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 titlexLabel
- the x-axis labelyLabel
- the y-axis labelxValues
- 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
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
This is a version of the constructor with no intial arrays. -
Plot
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
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
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
The minimum plot size including borders, in pixels (at scale=1) -
useTemplate
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
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
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 nullshape
- CIRCLE, X, BOX, TRIANGLE, CROSS, DOT, LINE, CONNECTED_CIRCLESlabel
- 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 coordinatesy
- the y coordinatesshape
- 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
This a version of addPoints that works with JavaScript. -
add
-
toShape
-
addPoints
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-coodinatesy
- the y-coodinateserrorBars
- the vertical error bars, may be nullshape
- CIRCLE, X, BOX, TRIANGLE, CROSS, DOT or LINE
-
addPoints
Adds a set of points to the plot using double ArrayLists. Must be called before the plot is displayed. -
getDoubleFromArrayList
-
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 arrowy1
- the y-coodinates of the beginning of the arrowx2
- the x-coodinates of the end of the arrowy2
- the y-coodinates of the end of the arrow
-
calculateDistance
public static double calculateDistance(int x1, int y1, int x2, int y2) -
drawVectors
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
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
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
-
addLegend
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
-
setLegend
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(), wherejustification
is Plot.LEFT, Plot.CENTER or Plot.RIGHT. Default is LEFT. -
setColor
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, usesetColor
beforedraw
. The frame and labels are always drawn in black. -
setColor
-
setColor
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, usesetColor
beforedraw
. The frame and labels are always drawn in black. -
setColor
Sets the drawing color for the next objects that will be added to the plot. -
setBackgroundColor
Set the plot frame background color. -
setBackgroundColor
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
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. Setstyle
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. Setstyle
to -1 to leave the style unchanged. Call updateImage() thereafter to make the change visible (if the image is shown already). -
setXLabelFont
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
Sets the yLabelFont; must not be null. -
setAntialiasedText
public void setAntialiasedText(boolean antialiasedText) Determines whether to use antialiased text (default true) -
changeFont
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
Draws the plot (if not done before) in an ImageProcessor and returns the ImageProcessor with the plot. -
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
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
Adjusts a Calibration object to fit the current axes. For log axes, the calibration refers to the base-10 logarithm of the value -
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 withsetFrozen(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
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
-
getResultsTable
Creates a ResultsTable with the plot data. Returns an empty table if no data. -
getResultsTable
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
-