# Class: Plot

plotting.Plot

Represents the actual plotting surface of a figure. This class is analogous to the Axes (opens new window) class in matplotlib. Each instance contains two ResponsiveCanvas instances, one for the background of the plot (axes, gridlines, etc.) and one for the foreground (data). An Axis attached to the plot is also created by default. Options for all these objects can be passed through the background, foreground and axis properties respectively in the options object. Plots contain their own coordinate system ("plot units") which are independent of the canvas coordinate system. The origin of this coordinate system can be set using setOrigin().

# Hierarchy

# Table of contents

# Properties

# Constructors

# Methods

# Properties

# Defaults

Static Defaults: Object

Name Default value
xLims [0, 10]
yLims [-10, 0]
origin {x: 0, y: 0}

# Type declaration

Name Type
xLims [number, number]
yLims [number, number]
origin { x: number = 0; y: number = 0 }
origin.x number
origin.y number

# Overrides

CanvasContainer.Defaults

# Defined in

plotting/Plot.ts:41 (opens new window)


# background

background: ResponsiveCanvas

Background canvas which contains static plot elements like axes and gridlines.

# Defined in

plotting/Plot.ts:27 (opens new window)


# foreground

foreground: ResponsiveCanvas

Foreground canvas which contains dynamic plot elements like data traces.

# Defined in

plotting/Plot.ts:31 (opens new window)


# axis

axis: Axis

Component which draws the axes.

# Defined in

plotting/Plot.ts:35 (opens new window)


# data

data: Trace[] = []

List of data traces present on the plot.

# Defined in

plotting/Plot.ts:39 (opens new window)


# parent

parent: PulsarObject

Parent instance of PulsarObject | PulsarObject.

# Inherited from

CanvasContainer.parent

# Defined in

core/CanvasContainer.ts:21 (opens new window)


# canvases

canvases: ResponsiveCanvas[] = []

List of the child ResponsiveCanvas | ResponsiveCanvas instances of the container.

# Inherited from

CanvasContainer.canvases

# Defined in

core/CanvasContainer.ts:25 (opens new window)


# scale

scale: Object

Scale of the internal coordinate system in canvas pixels to container units.

# Type declaration

Name Type
x number
y number

# Inherited from

CanvasContainer.scale

# Defined in

core/CanvasContainer.ts:29 (opens new window)


# resizeObserver

resizeObserver: ResizeObserver

The ResizeObserver (opens new window) instance which will watch the parent object to detect a resize event.

# Inherited from

CanvasContainer.resizeObserver

# Defined in

core/CanvasContainer.ts:39 (opens new window)


# xLims

xLims: [number, number] = CanvasContainer.Defaults.xLims

The horizontal limits of the internal coordinate system in container units.

# Inherited from

CanvasContainer.xLims

# Defined in

core/CanvasContainer.ts:43 (opens new window)


# yLims

yLims: [number, number] = CanvasContainer.Defaults.yLims

The vertical limits of the internal coordinate system in container units.

# Inherited from

CanvasContainer.yLims

# Defined in

core/CanvasContainer.ts:47 (opens new window)


# origin

origin: Object = CanvasContainer.Defaults.origin

The origin of the internal coordinate system in canvas units.

# Type declaration

Name Type
x number
y number

# Inherited from

CanvasContainer.origin

# Defined in

core/CanvasContainer.ts:51 (opens new window)

# Constructors

# constructor

new Plot(figure, options?)

# Parameters

Name Type Description
figure Figure The parent figure element.
options PlotOptions Options for the plot.

# Overrides

CanvasContainer.constructor

# Defined in

plotting/Plot.ts:49 (opens new window)

# Methods

# plot

plot(x, y, options): void

Adds data to the plot. x argument is optional. If it is omitted, the x data becomes the indices of the y data array. See plot (opens new window) function from matplotlib.

# Parameters

Name Type Description
x number[] | NDArray Data for the x-axis.
y number[] | NDArray Data for the y-axis
options Partial<{ traceColour: string ; traceStyle: "none" | "solid" | "dotted" | "dashed" | "dashdot" ; traceWidth: number ; markerColour: string ; markerStyle: "none" | "circle" | "plus" | "cross" | "arrow" ; markerSize: number ; visibility: boolean }> Options for the data.

# Returns

void

The data trace object.

# Defined in

plotting/Plot.ts:76 (opens new window)


# setXLims

setXLims(min, max): void

Sets the horizontal limits of the internal coordinate system in container units.

# Parameters

Name Type Description
min number The minimum horizontal value.
max number The maximum horizontal value.

# Returns

void

# Inherited from

CanvasContainer.setXLims

# Defined in

core/CanvasContainer.ts:112 (opens new window)


# setYLims

setYLims(min, max): void

Sets the vertical limits of the internal coordinate system in container units.

# Parameters

Name Type Description
min number The minimum vertical value.
max number The maximum vertical value.

# Returns

void

# Inherited from

CanvasContainer.setYLims

# Defined in

core/CanvasContainer.ts:127 (opens new window)


# setOrigin

setOrigin(...point): void

Sets the origin of the internal coordinate system in canvas pixels. x and y values may be passed or the value "centre" may be passed to conveniently set the origin to the centre of the canvas. Note that for the HTML5 canvas the origin is in the top-left corner by default and the x-axis points rightwards, while the y-axis points downwards.

# Parameters

Name Type Description
...point [number, number] | ["centre"] The new origin in canvas pixels.

# Returns

void

# Inherited from

CanvasContainer.setOrigin

# Defined in

core/CanvasContainer.ts:143 (opens new window)