Plot
plot functionplot xyplot pointsplot signalplot signalplot spectrumplot histogramplot fitplot addplot chartplot odeplot odeplot interpolate

plot function <expressions> <variable> <a> <b>


Description

    Draw one or several functions of one variable on [a, b] (1000 points), like a graphing calculator.
- the expressions use the syntax of 'math eval'; the session variables are written [k] and the angle unit is [_angle], as in 'math calc'
- several functions: a JSON array of expressions
- around a pole (1/x, tan(x)...) the y axis is limited to the useful part and the curve is cut

Parameters

    expressions:   An expression, or a JSON array of expressions - String - required
    variable:   The name of the variable, ex: x - String - required
    a:   The first value of the variable - Number - required
    b:   The last value of the variable - Number - required
admin
plot function "[\"sin(x)/x\", \"cos(x)\"]" "x" -10 10
mentdb
The chart is shown in the Plot tab of the output of the editor
One function
admin
plot function "exp(-x/2)*cos(3*x)" "x" 0 10
mentdb
The chart is shown in the Plot tab of the output of the editor
A special function
admin
plot function "[\"bessel_j(0, x)\", \"bessel_j(1, x)\", \"bessel_j(2, x)\"]" "x" 0 20
mentdb
The chart is shown in the Plot tab of the output of the editor
One function
admin
plot function "x^3-3*x" "x" -2.5 2.5
mentdb
The chart is shown in the Plot tab of the output of the editor
Function with a session variable
admin
-> "[w]" 2; plot function "sin([w]*x)" "x" 0 6.283185307179586
mentdb
The chart is shown in the Plot tab of the output of the editor
Normal density
admin
plot function "exp(-x^2/2)/sqrt(2*pi)" "x" -4 4
mentdb
The chart is shown in the Plot tab of the output of the editor

plot xy <json_x> <json_y>


Description

    Draw a curve through the points (x, y), in the order of the values.

Parameters

    json_x:   The x values - String - required
    json_y:   The y values - String - required
admin
plot xy "[0, 1, 2, 3, 4]" "[0, 1, 4, 9, 16]"
mentdb
The chart is shown in the Plot tab of the output of the editor
Line through measures
admin
plot xy "[0, 10, 20, 30, 40]" "[20.1, 35.2, 48.9, 61.0, 70.3]"
mentdb
The chart is shown in the Plot tab of the output of the editor
Parabola
admin
plot xy "[0, 0.5, 1, 1.5, 2]" "[0, 0.25, 1, 2.25, 4]"
mentdb
The chart is shown in the Plot tab of the output of the editor

plot points <json_x> <json_y>


Description

    Draw a cloud of points (x, y).

Parameters

    json_x:   The x values - String - required
    json_y:   The y values - String - required
admin
plot points "[1, 2, 3, 4, 5]" "[2.1, 3.9, 6.2, 7.8, 10.1]"
mentdb
The chart is shown in the Plot tab of the output of the editor
Measurements
admin
plot points "[0, 1, 2, 3, 4, 5]" "[0.1, 1.9, 4.2, 5.8, 8.1, 9.9]"
mentdb
The chart is shown in the Plot tab of the output of the editor
Random points (the result changes each time)
admin
plot points (stat dist_random "uniform" "[0, 1]" 50) (stat dist_random "uniform" "[0, 1]" 50)
mentdb
The chart is shown in the Plot tab of the output of the editor

plot signal <json_y>


Description

    Draw a signal (x = index of the value).

Parameters

    json_y:   The signal - String - required
admin
plot signal "[0, 0.8, 1, 0.3, -0.5, -1, -0.6, 0.2]"
mentdb
The chart is shown in the Plot tab of the output of the editor
A filtered signal
admin
plot signal (dsp moving_average "[1, 3, 2, 5, 4, 6, 5, 8, 7, 9]" 3)
mentdb
The chart is shown in the Plot tab of the output of the editor

plot signal <json_y> <fs>


Description

    Draw a signal sampled at fs Hz (x = time in seconds).

Parameters

    json_y:   The signal - String - required
    fs:   The sampling frequency (Hz) - Number - required
admin
plot signal "[0, 0.8, 1, 0.3, -0.5, -1, -0.6, 0.2]" 8
mentdb
The chart is shown in the Plot tab of the output of the editor
Signal sampled at 10 Hz (time in s)
admin
plot signal "[0, 0.951, 0.588, -0.588, -0.951, 0, 0.951, 0.588, -0.588, -0.951]" 10
mentdb
The chart is shown in the Plot tab of the output of the editor

plot spectrum <json_y> <fs>


Description

    Draw the amplitude spectrum of a signal (see 'dsp spectrum'): a sine of amplitude A at the frequency f gives a peak of height A at f.

Parameters

    json_y:   The signal - String - required
    fs:   The sampling frequency (Hz) - Number - required
admin
plot spectrum "[0, 0.8, 1, 0.3, -0.5, -1, -0.6, 0.2]" 8
mentdb
The chart is shown in the Plot tab of the output of the editor
Spectrum of a sine of 1 Hz sampled at 10 Hz
admin
plot spectrum "[0, 0.951, 0.588, -0.588, -0.951, 0, 0.951, 0.588, -0.588, -0.951]" 10
mentdb
The chart is shown in the Plot tab of the output of the editor

plot histogram <json_array> <nb_classes>


Description

    Draw the histogram of the values (classes of equal width, as 'stat histogram').

Parameters

    json_array:   The values - String - required
    nb_classes:   The number of classes (1 to 10000) - Number - required
admin
plot histogram (stat dist_random "normal" "[10, 2]" 1000) 25
mentdb
The chart is shown in the Plot tab of the output of the editor
Measurements in 5 classes
admin
plot histogram "[12.1, 11.4, 13.2, 10.9, 12.8, 11.7, 12.5, 13.0, 12.2, 11.9]" 5
mentdb
The chart is shown in the Plot tab of the output of the editor
Histogram of uniform values (the result changes each time)
admin
plot histogram (stat dist_random "uniform" "[0, 10]" 500) 10
mentdb
The chart is shown in the Plot tab of the output of the editor

plot fit <json_x> <json_y> <model> <variable>


Description

    Draw the points and a fitted model: the model is an expression, or directly the result of 'stat fit_model' or 'stat fit' (its field 'expression').

Parameters

    json_x:   The x values - String - required
    json_y:   The y values - String - required
    model:   An expression, or the result of 'stat fit_model' - String - required
    variable:   The name of the variable of the model, ex: x - String - required
admin
-> "[f]" (stat fit_model "a*exp(-x/tau)" "x" "[0, 1, 2, 3, 4]" "[10.2, 6.1, 3.6, 2.3, 1.3]" "{\"a\": 10, \"tau\": 2}"); plot fit "[0, 1, 2, 3, 4]" "[10.2, 6.1, 3.6, 2.3, 1.3]" [f] "x"
mentdb
The chart is shown in the Plot tab of the output of the editor
Linear fit of measures
admin
plot fit "[1, 2, 3, 4, 5]" "[2.1, 3.9, 6.2, 7.8, 10.1]" (stat fit "[1, 2, 3, 4, 5]" "[2.1, 3.9, 6.2, 7.8, 10.1]" "linear") "x"
mentdb
The chart is shown in the Plot tab of the output of the editor
A model written as an expression
admin
plot fit "[0, 1, 2, 3, 4]" "[10.2, 6.1, 3.6, 2.3, 1.3]" "10*exp(-x/2)" "x"
mentdb
The chart is shown in the Plot tab of the output of the editor

plot add <plot_result>


Description

    Add a chart to the chart of the Plot tab instead of replacing it (overlay): the parameter is the result of any plot command. Ex: draw measures, then add a theoretical curve.
Run it in a new execution, after the first chart: in one script only the result of the last statement is shown (to draw several series in one script, use 'plot chart').
The HOLD button of the Plot tab does the same for all the next charts.

Parameters

    plot_result:   The result of a plot command - String - required
admin
plot add (plot function "x^2" "x" 0 3)
mentdb
The chart is shown in the Plot tab of the output of the editor
admin
plot points "[0, 1, 2, 3]" "[0.1, 0.9, 4.2, 8.8]"; plot add (plot function "x^2" "x" 0 3)
mentdb
The chart is shown in the Plot tab of the output of the editor
Two functions on the same chart
admin
plot function "sin(x)" "x" 0 6.283185307179586; plot add (plot function "cos(x)" "x" 0 6.283185307179586)
mentdb
The chart is shown in the Plot tab of the output of the editor

plot chart <json_chart>


Description

    Draw a chart described in JSON: {"title", "x_label", "y_label", "log_x", "log_y", "series": [{"name", "type": "line" | "points" | "bars", "x": [...], "y": [...]}]}.
'x' is optional (0, 1, 2... by default); a null in 'y' cuts the line. At most 50 series of 100000 points.

Parameters

    json_chart:   The chart (JSON object) - String - required
admin
plot chart "{\"title\": \"Two series\", \"series\": [{\"name\": \"a\", \"y\": [1, 3, 2, 4]}, {\"name\": \"b\", \"type\": \"points\", \"y\": [2, 2, 3, 3]}]}"
mentdb
The chart is shown in the Plot tab of the output of the editor
Logarithmic y axis with labels
admin
plot chart "{\"title\": \"Decay\", \"x_label\": \"t (s)\", \"y_label\": \"N\", \"log_y\": true, \"series\": [{\"name\": \"N\", \"x\": [0, 1, 2, 3, 4], \"y\": [1000, 368, 135, 50, 18]}]}"
mentdb
The chart is shown in the Plot tab of the output of the editor
Bars
admin
plot chart "{\"title\": \"Sales\", \"series\": [{\"name\": \"2025\", \"type\": \"bars\", \"y\": [12, 15, 9, 20]}]}"
mentdb
The chart is shown in the Plot tab of the output of the editor
A null cuts the line
admin
plot chart "{\"series\": [{\"name\": \"sensor\", \"y\": [1, 2, null, 4, 5]}]}"
mentdb
The chart is shown in the Plot tab of the output of the editor

plot ode <result>


Description

    Draw the result of 'num ode' (with a JSON object of equations): each variable as a function of t; the event is shown as a point

Parameters

    result:   The result of num ode - String - required
admin
plot ode (num ode "{\"x\": \"v\", \"v\": \"-x\"}" "{\"x\": 1, \"v\": 0}" 0 10)
mentdb
The chart is shown in the Plot tab of the output of the editor
Lotka-Volterra predator-prey
admin
plot ode (num ode "{\"prey\": \"1.1*prey - 0.4*prey*pred\", \"pred\": \"0.1*prey*pred - 0.4*pred\"}" "{\"prey\": 10, \"pred\": 10}" 0 50 "{\"points\": 1000}")
mentdb
The chart is shown in the Plot tab of the output of the editor
Logistic growth
admin
plot ode (num ode "{\"N\": \"0.8*N*(1-N/100)\"}" "{\"N\": 5}" 0 15 "{\"points\": 200}")
mentdb
The chart is shown in the Plot tab of the output of the editor

plot ode <result> <x> <y>


Description

    Draw a variable of the result of 'num ode' as a function of another one: phase portrait, trajectory (y as a function of x)

Parameters

    result:   The result of num ode - String - required
    x:   The variable on the x axis - String - required
    y:   The variable on the y axis - String - required
admin
plot ode (num ode "{\"x\": \"v\", \"v\": \"-x\"}" "{\"x\": 1, \"v\": 0}" 0 10) "x" "v"
mentdb
The chart is shown in the Plot tab of the output of the editor
Phase portrait of the Van der Pol oscillator
admin
plot ode (num ode "{\"x\": \"v\", \"v\": \"2*(1-x^2)*v - x\"}" "{\"x\": 0.5, \"v\": 0}" 0 30 "{\"points\": 2000}") "x" "v"
mentdb
The chart is shown in the Plot tab of the output of the editor
Trajectory of a projectile with air resistance
admin
plot ode (num ode "{\"x\": \"vx\", \"y\": \"vy\", \"vx\": \"-0.05*sqrt(vx^2+vy^2)*vx\", \"vy\": \"-_g0-0.05*sqrt(vx^2+vy^2)*vy\"}" "{\"x\": 0, \"y\": 0, \"vx\": 30, \"vy\": 30}" 0 10 "{\"points\": 400, \"event\": \"y\", \"direction\": -1}") "x" "y"
mentdb
The chart is shown in the Plot tab of the output of the editor
Phase portrait of the predator-prey model
admin
plot ode (num ode "{\"prey\": \"1.1*prey - 0.4*prey*pred\", \"pred\": \"0.1*prey*pred - 0.4*pred\"}" "{\"prey\": 10, \"pred\": 10}" 0 50 "{\"points\": 1000}") "prey" "pred"
mentdb
The chart is shown in the Plot tab of the output of the editor

plot interpolate <xs> <ys> <mode>


Description

    Draw the points and the interpolating curve (mode: see 'num interpolate')

Parameters

    xs:   JSON array of x - String - required
    ys:   JSON array of y - String - required
    mode:   The mode of interpolation - String - required
admin
plot interpolate "[0, 1, 2, 3, 4, 5]" "[0, 0.8, 0.9, 0.1, -0.8, -1]" "cubic"
mentdb
The chart is shown in the Plot tab of the output of the editor
Pchip: no overshoot on monotone data
admin
plot interpolate "[0, 1, 2, 3, 4]" "[0, 0, 1, 1, 1]" "pchip"
mentdb
The chart is shown in the Plot tab of the output of the editor
Natural spline
admin
plot interpolate "[0, 1, 2, 3, 4]" "[1, 3, 2, 4, 3]" "natural"
mentdb
The chart is shown in the Plot tab of the output of the editor
Akima
admin
plot interpolate "[0, 1, 2, 3, 4, 5, 6]" "[0, 0, 0, 1, 0, 0, 0]" "akima"
mentdb
The chart is shown in the Plot tab of the output of the editor