Plotting

Data can be added to plots within the LbyM app through Logo code. Currently, all commands can be found in the starter project "Plotting Demo". As of this writing only scatter plots are supported with single data sets.

Plots

To define a new plot, first use the keywords to set all relevant options. Then create the plot with the function 'show-plot'. Required options include plot position, x-data and y-data. The data sources should be variables, and those variables should be arrays. The chart will listen for changes to the defined variables and will update when the data is updated.

Example:

to make-plot
  one-plot
  x-label "Time
  y-label "Data
  x-data "xDataOne
  y-data "yDataOne
  show-plot
end

Plots can be made with multiple data sources by passing an array in place of the string for x-data or y-data. Sources are paired in order between the arrays. If one axis only has one data source it will be used with all data sources on the other axis. This is most commonly used with time on the x axis.

to plot-two-things
  one-plot
  x-label 'Time'
  y-label 'Data'
  x-data 'time-list'
  y-data ['thing1-data' 'thing2-data']
end

Options

Function NameInput TypeDefaultDescription
one-plot / bottom-plot / top-plotNoneNo default - requiredDefine the position of the plot to be created
plot-titleStringundefinedSet title text for plot
x-labelStringundefinedSet text to label x-axis
y-labelStringundefinedSet text to label y-axis
x-dataString (variable name) or arrayNo default - requiredSet variable to map to x axis
y-dataString (variable name) or arrayNo default - requiredSet variable to map to y axis
limits-xNumbers (2)undefinedSet domain (number range of x axis) between two numbers
limits-yNumbers (2)undefinedSet range (number range of y axis) between two numbers
limitsNumbers (4)undefinedSet domain and range [xmin, xmax, ymin, ymax]
x-ticksNumbersundefinedSet step size of tick marks on x axis
y-ticksNumbersundefinedSet step size of tick marks on y axis

After setting options, calling "show-plot" is necessary in order to generate the plot in the 'plots' tab.

Last updated on December 22, 2022