This page describes the functions and methods supported by the XYPlot class for sending data, setting properties and controlling the X-Y Plot visualizer from your Arduino sketch. The xy-plot visualizer shows numerical data on a graph with separate values for the x (horizontal) and y (vertical) axes.

Data is grouped in series for plotting. Series are identified using a series name and new values are appended to the series and shown on the plot as they arrive. You can assign different marker symbols, lines and colors to each series. A series may be connected to the left or right y-axis.

By default, all 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 XYPlot constructor.

Arduino Library

You’ll need to install our Arduino library for MegunoLink to use the XYPlot class.

Check out our getting started with plotting data guide for an introduction to plotting with MegunoLink.

Example

This example sends the voltage from the first two analog channels as x and y values to MegunoLink every 200 ms.

Methods

These methods are specific to XY plots.

Constructor:

  • XYPlot(ChannelName — optional )

Send single measurement:

  • SendData(SeriesName, XValue, YValue, SeriesProperties — optional )
  • SendData(SeriesName, XValue, YValue, Color, LineStyle, LineWidth, MarkerStyle)
  • SendData(SeriesName, XValue, YValue, RGBColor, LineStyle, LineWidth, MarkerStyle)
  • SendData(SeriesName, XValue, YValue, NumberOfDecimalPlaces, SeriesProperties — optional )
  • SendData(SeriesName, XValue, YValue, NumberOfDecimalPlaces, Color, LineStyle, LineWidth, MarkerStyle)

Send multiple measurements:

  • SendData(SeriesName, XValues, YValues, NumberOfValues, SeriesProperties — optional )
  • SendData(SeriesName, XValues, YValues, NumberOfValues, NumberOfDecimalPlaces, SeriesProperties — optional )

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

Detailed Descriptions

The parameters and functions for the XYPlot class are described in detail below. Optional parameters are surrounded by []s. Text parameters support memory string and flash strings (where available).

XY Plot Constructor

Constructs an x-y plot variable, which can be used to send data, format and control XY Plot visualizers.
XYPlot([ChannelName], [Destination])

Parameters
Name Type Required? Description
ChannelName const char*, const __FlashStringHelper* 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

XYPlot has a variety of methods to send data to MegunoLink. They all require a series name, an x-value and a y-value. You can also include styling information (such as the marker symbol or line color) and the number of decimal places (for float or double values). Finally, you can send an array of x- and y-values in one go. Sending styling information overrides the style in MegunoLink.

The available methods for sending a single data-point are:
SendData(SeriesName, XValue, YValue, [SeriesProperties])
SendData(SeriesName, XValue, YValue, Color, [LineStyle], [LineWidth], [MarkerStyle], [AxisOption])
SendData(SeriesName, XValue, YValue, RGBColor, [LineStyle], [LineWidth], [MarkerStyle], [AxisOption])
SendData(SeriesName, XValue, YValue, NumberOfDecimalPlaces, [SeriesProperties])
SendData(SeriesName, XValue, YValue, NumberOfDecimalPlaces, Color, [LineStyle], [LineWidth], [MarkerStyle], [AxisOption])
SendData(SeriesName, XValue, YValue, NumberOfDecimalPlaces, RGBColor, [LineStyle], [LineWidth], [MarkerStyle], [AxisOption])

The available methods for sending an array of data-points are:
SendData(SeriesName, XValues, YValues, NumberOfValues, [SeriesProperties])
SendData(SeriesName, XValues, YValues, NumberOfValues, NumberOfDecimalPlaces, [SeriesProperties])

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.
XValue Number Yes The x-value to add to the plot for SeriesName
YValue Number Yes The y-value to add to the plot for SeriesName
XValues Array of numbers Yes An array of NumberOfValues x-values to add to the plot for SeriesName
YValues Array of numbers Yes An array of NumberOfValues y-values to add to the plot for SeriesName
NumberOfValues Number Yes The number of values in the XValues and YValues arrays.
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.

More Information

For more information on plotting and formatting see:

Start typing and press Enter to search