Plots are represented by terms of the sort Plot ⊆ LzPlotTerm, with LzPlotTerm ⊆ PharoTermClass. These definitions ensure that plot terms are created as instances of LzPlotTerm
LzTermInContext subclass: #LzPlotTerm
instanceVariableNames: ''
classVariableNames: ''
package: 'Leibniz2-Plotting'
.
Line plots can be defined by an array of (x, y) pairs:
linePlot(Array1D((ℝ, ℝ))) : Plot
or by separate arrays for x and y values:
linePlot(Array1D(ℝ), Array1D(ℝ)) : Plot
Another possibility is providing a function plus an array of x values:
linePlot(ℝ → ℝ, Array1D(ℝ)) : Plot
The y values are then computed from:
linePlot(f:(ℝ → ℝ), x:Array1D(ℝ)) ⇒ linePlot(x, f[x])
A line plot for an array of points:
linePlot({[(0, 1), (1, 2), (3, -1), (4, 1/2)]})
A line plot of a function (the squaring function from functionExample Functions/realFunction):
functionExample square[{[1, 2, 3]}] ⇒ {[1, 4, 9]}
functionExample linePlot(square, {[0, 1/2, 1, 3/2, 2, 5/2, 6]})