Plotter:
Filter:
Classes | GUI > Accessories

Plotter : Object

Plot numerical data on a window or view
Source: PlotView.sc

Description

Plot data of up to three dimensions on a Window or UserView.

Keyboard shortcuts

When the plotter window has focus, the following keyboard shortcuts can be used to change the display:

+ / -vertical zoom
=compare plot channels
ntoggle normalize display (0..1) / (-1..1), or fit range
stoggle superposition (see: superpose)
mswitch plot mode (see: Plotter: -plotMode)
etoggle editing (see: Plotter: -editMode)
gtoggle horizontal (domain) grid
Gtoggle vertical (codomain) grid
pprint curve
ctrl-+ / -zoom font
alt-clickpost value

Method extensions

Plotter extends other classes with methods. To see what classes implements plot, see Methods: plot

plot(args)

plotGraph(n,from,to,...)

Class Methods

Plotter.new(name, bounds, parent)

Arguments:

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.

Discussion:

Inherited class methods

Instance Methods

Accessing Instance Variables

.makeWindow(argParent, argBounds)

Open given plotter in a new window or within a given composite view.

Arguments:

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).

.plotMode

.plotMode = modes

Get/Set the style of data display. This can be an array of different modes for multi-channel data.

Arguments:

modes

A Symbol or an Array of Symbols.

If modes.size < numChannels, the plots will wrap around the array of modes.

Returns:

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 Symbol is returned.

Available modes:

\linearconnecting data points with linear interpolation
\pointsdraw data points only
\plinescombination of lines and points
\levelshorizontal lines
\stepsconnecting data points with step interpolation
\barsbar graph with filled bars

Discussion:

.setProperties( ... pairs)

Set properties of all plot views. Defaults are taken from GUI.skin.at(\plot);

Arguments:

... pairs

A list of symbol,value pairs. Supported properties:

  • font
  • fontColor
  • gridColorX
  • gridColorY
  • plotColor (an Array)
  • backgroundColor
  • gridLinePattern
  • gridLineSmoothing ( Boolean )
  • labelX
  • labelY
  • gridOnX ( Boolean )
  • gridOnY ( Boolean )

Discussion:

Example:

.editMode

.editMode = value

If the edit mode is set to true, the data may be edited via cursor.

.resolution

.resolution = value

Set the minimum number of pixels between data points (default: 1)

.findSpecs

.findSpecs = value

If true (default: true), specs are derived from new data (using min and max values) automatically.

.superpose

.superpose = flag

If set to true, plotter displays channels on top of each other (keyboard shortcut: s)

.value

.value = arrays

Return or set the data values. Data may be numerical arrays of up to 3 dimensions.

.setValue(arrays, findSpecs: true, refresh: true, separately: true, minval, maxval, defaultRange)

Set the data values, with additional arguments determining how the plot is updated.

Arguments:

arrays

Arrays of data to plot. Data may be numerical arrays of up to 3 dimensions.

findSpecs

A Boolean. If true (default), bounds of the plot(s) are determined automatically. If false, previous bounds will persist.

refresh

A Boolean. If true (default), refresh the view immediately.

separately

A Boolean. If true (default), min and max of each set of data will be calculated and displayed separately for each plot. If false, each plot's range on the y-axis will be the same.

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.

.data

Reference to the current internal data.

.cursorPos

Returns:

the last cursorPos (a Point).

.plots

Returns:

the single subplots (a Plot).

.specs

.specs = argSpecs

Set or get the spec for the y-axis (codomain).

See also examples.

.domainSpecs

.domainSpecs = argSpecs

Set or get the spec for the x-axis (domain).

Discussion:

The default domainSpec when setting your Plotter -value is a linear spec in the range [0, value.size-1]. Unless you set -domain, your values are displayed as evenly sampled between the minval and maxval of the domainSpecs.

If a new -value is set, you will need to update your domainSpecs.

For examples, see -domain and examples.

.domain

.domain = domainArray

Set or 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.

Discussion:

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.

Example:

A more elaborate example can be found in the examples.

.plotColor

.plotColor = colors

Set or get the colors of your data plot.

Arguments:

colors

This can be an Array of Colors for multichannel data, or a single Color to map to all channels.

If colors.size < numChannels, the plots will wrap around the array of colors.

Returns:

An Array of Colors, unless there is only one color specified or if all colors of a multi-channel plot are the same, in which case a Color is returned.

.editFunc

.editFunc = value

Supply a function which is evaluated when editing data. The function is called with the arguments: plotter, plotIndex, index, val, x, y.

Discussion:

Example:

Inherited instance methods

Undocumented instance methods

.bounds

.bounds = value

.calcDomainSpecs

.calcSpecs(separately: true, minval, maxval, defaultRange)

.draw

.drawBounds

.drawFunc

.drawFunc = value

.editData(x, y)

.editPlotIndex

.editPos

.getDataPoint(x, y)

.gui

.interactionView

.makePlots

.maxval = val

.minval = val

.name

.name = value

.normalized

.normalized = value

.numChannels

.numFrames

.parent

.parent = value

.pointIsInWhichPlot(point)

.postCurrentValue(x, y)

.prReshape(item)

.print

.refresh

.updatePlotBounds

.updatePlotSpecs

.updatePlots

Examples

Changing global defaults

The default styles are kept (and may be overridden) in GUI.skin.at(\plot). See also GUI help.