This page describes the functions and methods supported by the TimePlot class for sending data, setting properties and controlling the Time Plot visualizer from your Arduino sketch. Check out our getting started with Arduino plotting guide for an introduction to plotting data in MegunoLink.

The TimePlot visualizer shows numerical data on a graph with time as the x-axis. Your computer’s time is used to time-stamp each value received from your Arduino sketch. Custom time strings can be sent using the raw message format.

Data is grouped in series for plotting. The series are identified with a Series Name and new values are appended to the series and shown on the plot as they arrive. You can assign different marker, line and axes to each series.

By default, all the data sent for plotting is shown in the visualizer. You can create multiple plots and control which data is shown on each using message channels. To use channels, supply a channel name in the TimePlot constructor.

You will need to install our Arduino Library for MegunoLink to use the TimePlot class.

Check out our Plotting Data guide for an introduction to plotting with MegunoLink.

Methods

The following methods are specific to Time Plots:

The following methods, common to all plot visualizers, can be used to control the plot’s appearance:

Detailed Descriptions

The parameters and functions for Time Plot methods are given. Optional parameters are surrounded by []‘s. Text parameters support memory strings and flash strings (where available).

Time Plot Constructor

Constructs a time plot variable, which can be used to send data, format and control Time Plot visualizers.
TimePlot([ChannelName], [Destination])

Parameters
Name Type Required? Description
ChannelName Text No sets the channel used for all methods called on the variable. If missing, data is sent to the default channel
Destination Print No the stream used for all methods called on the variable. If missing, data is sent to the standard Serial port

Sending Data

Methods to send numeric data to a Time Plot visualizer. Select a function based on the parameters you want to supply.

Parameters
Name Type Required? Description
SeriesName Text Yes The name of the series the data belongs to. A series is a collection of points, optionally connected by a line.
TimeStamp time_t No A time-stamp for the data point. MegunoLink uses the computer’s time if a time-stamp is not supplied.
YValue Number Yes The y-value to add to the plot for SeriesName
SeriesProperties Text No A series property string to set the series style
Color Plot::Colors Yes One of the supported color constants to set the series line and marker color
RGBColor 32 bit number Yes A 24 bit RGB color. In hex the components are: 0xRRGGBB where RR, GG and BB are 8 bit values for the red, green and blue components of the color.
LineStyle Plot::LineStyle No One of the supported line-style constants to set the series line style. Defaults to Plot::Solid
LineWidth Number No The thickness to draw the series line. Defaults to 1
MarkerStyle Plot::MarkerStyle No One of the supported marker-style constants to set the series marker style. Defaults to Plot::Circle
AxisOption Plot::AxisOption No One of the supported axis option constants to set which axis the series is linked to. Defaults to Plot::DefaultAxis, which doesn’t change the axis the series is linked to
DecimalPlaces Number Yes The precision to use when sending floating-point numbers.

X-Axis Limits

Change the time-span shown on the plot’s x-axis.
SetXRange(TimespanHours)

Auto Scroll behaviour

Enable/disable the Time-Plot’s auto-scroll behavior. When auto-scroll is enabled, older data scrolls off the left edge of the chart. Data is not lost; zoom or pan to see data that has scrolled out of view.

  • Run([Enable]): when Enable is true or missing, turns on auto-scroll; if false, auto-scroll is disabled.
  • Stop(): stop auto-scroll; stops the plot from panning automatically.

Example

This example sends the current voltage on analog channel 0 to MegunoLink Pro every 200 ms.

More Information

For more information on plotting and formatting see:

Start typing and press Enter to search