Plot data of up to three dimensions on a Window or UserView.
When the plotter window has focus, the following keyboard shortcuts can be used to change the display:
+ / - | vertical zoom |
= | compare plot channels |
n | toggle normalize display (0..1) / (-1..1), or fit range |
s | toggle superposition (see: superpose) |
m | switch plot mode (see: Plotter: -plotMode) |
e | toggle editing (see: Plotter: -editMode) |
g | toggle horizontal (domain) grid |
G | toggle vertical (codomain) grid |
p | print curve |
ctrl-+ / - | zoom font |
alt-click | post value |
Plotter extends other classes with methods. To see what classes implements plot, see Methods: plot
name |
Plot window title. |
bounds |
The window bounds (a Rect). |
parent |
Either a Window / View may be passed in - then the plot is embedded. Otherwise a new Window is created. |
Open given plotter in a new window or within a given composite view.
See the Embedding in another View or GUI example.
argParent |
Either a Window or View may be passed in - then the plot is embedded. Otherwise a new Window is created. |
argBounds |
The window bounds (a Rect). |
Get/Set the style of data display. This can be an array of different modes for multi-channel data. Available modes:
\linear | connecting data points with linear interpolation |
\points | draw data points only |
\plines | combination of lines and points |
\levels | horizontal lines |
\steps | connecting data points with step interpolation |
\bars | bar graph with filled bars |
modes |
A Symbol or an Array of Symbols. If |
An Array of Symbols, unless there is only one mode specified or if all modes of a multi-channel plot are the same, in which case a single Symbol is returned.
Set or get the colors of your data plot.
colors |
This can be an Array of Colors for multichannel data, or a single Color to map to all channels. If |
If true
, plotter displays channels overlaid on a single plot. (keyboard shortcut: s)
Get/set the label for the x-axes. Can be a String or an Array of Strings, or nil
to remove the label. See Axis labels example below.
Get/set the label for the y-axes. Can be a String or an Array of Strings, or nil
to remove the label. See Axis labels example below.
Get/set whether the corresponding ControlSpec: -units are displayed as labels. The state of -unitLocation determines whether the units are shown as axis labels or appended to the tick labels.
bool |
A |
When enabling showUnits
, axis or tick labels will only be updated to show the units when the axisLabelX/Y
or grid labelAppendString
properties are nil
, empty, or were previously set to show the spec units — i.e. showUnits
won't overwrite a label that has been explicitly set.
See Unit labels example below.
Get/set the label type on which the Spec
ControlSpec: -units are shown.
See the Discussion in -showUnits about the interraction with pre-existing labels at the location, and Unit labels example below.
location |
A |
Set properties of all plot views. Defaults are taken from GUI.skins.at(\plot);
... pairs |
A list of symbol,value pairs. Supported properties: |
Example:
Set one or more properties of the DrawGridX
or DrawGridY
used by all Plots
.
axis |
A | ||||||||||||||||||||||||||
... propertyPairs |
Key value pairs, listed as successive arguments, of the properties to change and their new values. The property key is a Any of setters of
The properties |
This is a convenience method to set the grid properties for all Plot
s to the same values. An Example:
To set the properties of grids on each Plot
separately, iterate over the plots:
Get the value of a grid property. See -setGridProperties for a list of available properties.
axis |
A |
property |
The property name as a |
As a convenience method, getGridProperty
assumes that properties across all Plot
s are the same (as would be the case if set by -setGridProperties) so returns a single value. Alternatively, properties from individual plot grids can be collected by iterating over the plots:
Set whether a Rect is drawn around the boundary of the grid. Setting to false
disables any bounding grid lines (including "base" lines).
bool |
A |
In some cases, the GridLines of the grid will not fall on the minimum or maximum of it's spec's range. Using -drawGridBaseLines or -drawGridBoundingRect will give the appearance of grid lines at the lower end ("base") of the grid, or at both ends of the grid, respectively.
Set whether a line is drawn at the lower extent of the grid axes. Setting to false
disables any bounding grid lines (including a bounding Rect
). See also the Discussion in -drawGridBoundingRect.
bool |
A |
Set or get the spec for the y-axis (codomain).
See also the Explicit domain and axis specs example below.
Set or get the spec for the x-axis (domain).
See also the Explicit domain and axis specs example below.
When setting your Plotter
-value, the default domainSpecs is a linear spec in the range [0, value.size-1]
(i.e. the indices of the values). Therefore, your values are displayed as evenly sampled between the minval
and maxval
, unless you have explicitly set the -domain values.
If a new -value is set, you will need to update your domainSpecs.
Set/get the x-axis positions of your data points. The size of the domainArray
must equal the size of your -value array, i.e. a domain value specified for each data point.
See also the Explicit domain and axis specs example below.
Domain values are mapped into the range of the -domainSpecs, so need not be evenly distributed. If -domain is set to nil
, your values are displayed as evenly sampled between the minval
and maxval
of the -domainSpecs.
Currently, for multichannel data plots, it's assumed that all channels of data share a single -domain. I.e. domainArray
must be an Array of rank 1.
If a new -value is set, you will need to update your -domain.
Set the minimum number of pixels between data points (default: 1)
Return or set the data values. Data may be numerical arrays of up to 3 dimensions.
Set the data values, with additional arguments determining how the plot is updated.
arrays |
Arrays of data to plot. Data may be numerical arrays of up to 3 dimensions. |
findSpecs |
A |
refresh |
A |
separately |
A |
minval |
(Optional) The minimum value displayed on the y-axis. |
maxval |
(Optional) The maximum value displayed on the y-axis. |
defaultRange |
(Optional) A default range for the y-axis in the case that the max and min values of the data are identical. |
If true
, specs are derived from new data (using min and max values) automatically. Default: true
.
Reference to the current internal data (with shape up to depth of 3).
If the edit mode is set to true, the data may be edited via cursor.
Supply a function which is evaluated when editing data. The function is called with the arguments: plotter
, plotIndex
, index
, val
, x
, y
.
Example:
The last cursorPos (a Point).
The units of the grid specs are shown as labels, either axis labels or appended to tick labels. Unit labels won't overwrite preexisting labels, and can be disabled altogether.
The default styles are kept (and may be overridden) in GUI.skins.at(\plot)
. See also GUI help.