RedcrabX – Plot Input Guide

Reference for expression syntax and options in the Plot Box (ScottPlot)  |  Version 1.0

Table of Contents


1. Overview

The Plot Box renders 2D scatter/line plots using the ScottPlot library. Data is provided as array expressions that are evaluated against variables defined in Calculator (MathBox) boxes within the workspace.

The Plot Box toolbar contains two main input fields:

FieldPurpose
ExpressionOne or more Y-axis data expressions (the main input)
X-VariableOptional X-axis data expression (defaults to index 0, 1, 2, …)

2. Expression Field

The expression field accepts any value that resolves to a 1-D array of numbers.

InputSyntaxDescription
Variable nameAUses the array stored in variable A
Inline array[10, 20, 35, 18]Literal list of values
Range[1..100]Integer sequence 1, 2, … 100
Range with step[0..6.28:0.01]0.00, 0.01, 0.02, … 6.28
Array expressionA * 2 + 1Element-wise arithmetic on array A
Function of arraysin(T)Applies sin to each element of array T
Tip: Define arrays in a Calculator box first, e.g. T = [0..6.28:0.01], then reference T in the plot expression.

3. X-Variable Field

If left empty, the X-axis uses the element index (0, 1, 2, …). Fill in any array expression to provide explicit X values. The X array must have the same number of elements as each Y series.

ExampleMeaning
TUse variable T as X values
[0..6.28:0.01]Inline range as X values
A * 0.5Computed expression as X values

4. Inline X/Y Syntax

Instead of using the separate X-Variable field, you can specify both X and Y data directly in the Expression field using curly-brace notation. This overrides the X-Variable field for the current plot.

{x: x-expression, y: y-expression}
ExampleDescription
{x: T, y: sin(T)}Plot sin(T) against T
{x: T, y: [sin(T), cos(T)]}Two series sharing the same X data
{x: [1..10], y: A}Inline X range with variable Y

5. Multiple Series

Separate multiple Y expressions with a semicolon ; to plot several curves in the same diagram.

sin(T); cos(T); tan(T)

Each series gets its own color and legend entry automatically.

6. Named Series

Assign a custom legend label with the syntax name = expression. The name must be a valid identifier (letters, digits, underscore).

Temperature = A; Pressure = B

The legend will show "Temperature" and "Pressure" instead of the raw expressions.

Note: Comparison operators (==, <=, >=, !=) are not confused with naming. Only a bare = preceded by a valid identifier triggers the naming feature.

7. List Expansion

Wrap multiple expressions in square brackets separated by commas to expand them into individual series. This is a shorthand for semicolon separation.

ShorthandEquivalent
[A, B, C]A; B; C
[sin(T), cos(T)]sin(T); cos(T)
Important: Range literals like [1..10] and matrix literals containing .. or ; are not expanded — they are treated as single array expressions.

8. Matrix Support

Matrices defined in Calculator boxes can be plotted in several ways.

8.1 Columns as series

cols(M)

Each column of matrix M becomes a separate series. Legend labels are automatically generated as M[,0], M[,1], etc.

8.2 Rows as series

rows(M)

Each row of matrix M becomes a separate series. Legend labels: M[0,], M[1,], etc.

8.3 Bare matrix variable

M

When a bare matrix variable name is entered, its columns are automatically expanded into individual series (same as cols(M)).

8.4 Named matrix series

Data = cols(M)

Legend labels become Data[0], Data[1], etc.

9. Function Expressions

You can apply any supported math function to an array variable or expression. The function is applied element-wise.

ExpressionResult
sin(T)Sine of each element in T
sqrt(A)Square root of each element in A
log(A)Natural log of each element in A
abs(A - 5)Absolute difference from 5
A^2 + B^2Element-wise combination of two arrays
Degrees vs. Radians: The toolbar toggle switches trigonometric functions between degree and radian mode. Default is degrees.

10. Line Colors & Widths

The Colors and Widths fields in the toolbar control the appearance of each series. Values are separated by ; and assigned to series in order.

Colors

#ff0000; #00aa00; blue

Accepts hex codes (#RRGGBB) or named colors. If fewer colors than series are specified, later series use default colors.

Line widths

2; 1.5; 3

Numeric values controlling the stroke width of each series line.

11. Axis Labels

The X-Label and Y-Label fields set custom axis titles. If left empty, automatic labels are generated:

ConditionAuto X-LabelAuto Y-Label
No X variableIndexExpression text
X variable setX variable nameExpression text
Log scale activelog10(…)log10(…)
Multiple series(same)Value

12. Toolbar Options

OptionDescription
Degrees / RadiansSwitches trigonometric function input mode
Show LegendToggles the legend panel on/off
Legend PositionMoves the legend (e.g. TopRight, BottomLeft, etc.)
Show GridToggles background grid lines
Show MarkersToggles data-point markers on each series
Log Scale YApplies log₁₀ transformation to Y values (values must be > 0)
Log Scale XApplies log₁₀ transformation to X values (values must be > 0)

13. Complete Examples

Example 1 – Simple sine curve

In a Calculator box:

T = [0..6.28:0.01]

In the Plot Box expression field:

sin(T)

In the X-Variable field:

T

Example 2 – Multiple trig functions with inline X

{x: T, y: [sin(T), cos(T)]}

Example 3 – Named series with custom colors

Expression:

Revenue = A; Cost = B; Profit = A - B

Colors:

#2e7d32; #c62828; #1565c0

Example 4 – Matrix columns

Given a 10×3 matrix M defined in a Calculator box:

cols(M)

Plots three series: M[,0], M[,1], M[,2].

Example 5 – Logarithmic Y scale

Expression:

[1, 10, 100, 1000, 10000]

Enable Log Scale Y in the toolbar. The plot shows values evenly spaced on a log₁₀ axis.

Example 6 – Computed expression

A^2 + 2*A + 1

Plots the polynomial for each element of array A.

Example 7 – Combined named + list syntax

Waves = [sin(T), cos(T)]; Envelope = abs(sin(T))

Expands to three series: sin(T), cos(T), and abs(sin(T)), with "Waves[0]", "Waves[1]", and "Envelope" as legend labels.


RedcrabX Plot Input Guide  |  Generated for ScottPlot-based Plot Box