ThingSpeak

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

thingSpeakPlot

Create 2-D line plot

Syntax

thingSpeakPlot(X,Y)
thingSpeakPlot(Y)
thingSpeakPlot(X,Y,Name,Value)

Description

example

thingSpeakPlot(X,Y) plots vector Y versus vector X. If X or Y is a matrix, the vector is plotted versus the rows or columns of the matrix, whichever line up. If X is a scalar and Y is a vector, disconnected line objects are created and plotted as discrete points vertically at X.

example

thingSpeakPlot(Y) plots the columns of Y versus their index.

example

thingSpeakPlot(X,Y,Name,Value) lets you specify line types, colors, and data point symbols using additional options specified by one or more name-value pair arguments.

Examples

collapse all

Create a line plot of a sine wave.

x = 0:pi/100:2*pi;
y = sin(x);
thingSpeakPlot(x,y)

Create line charts from a magic four matrix.

Y = magic(4);
thingSpeakPlot(Y)

Create line chart with specific line properties.

Specify the following properties:

  • Line style: dashed line

  • Line width: 2

  • Line color: green

  • Marker type: square

x = -pi:pi/10:pi;
y = tan(sin(x)) - sin(tan(x));
thingSpeakPlot(x,y,'LineStyle','--','LineWidth',2,'Color','green','Marker','s')

Create a line plot on a log scale.

x = 0:0.1:10;
y = exp(x);
thingSpeakPlot(x,y,'YScale','log')

Create a plot with a grid in the background.

x = linspace(0,10);
y = sin(x);
thingSpeakPlot(x,y,'Grid','on')

Create a line plot with date values from 1900 through 1990, with 10-year intervals on the x-axis.

t = (1900:10:1990)';
p = [75.995  91.972 105.711 123.203 131.669 ...
    150.697 179.323 203.212 226.505 249.633]';
thingSpeakPlot(datetime(t,1,1),p,'Grid','on')

Create a line plot with datetime values on the x-axis, in a sequence of dates. Display 10 calendar days.

t = datetime(2015,6,28) + caldays(1:10);
y = rand(1,10);
thingSpeakPlot(t,y,'Grid','on')

Create a line plot with a title and axis labels.

thingSpeakPlot([1:10].^2,'XLabel','Time','YLabel','Population','Title','Population in the 1900s');

Input Arguments

collapse all

X values, specified as a scalar, vector, or matrix. X can be a numeric array, logical array, or datetime array.

Y values, specified as a scalar, vector, or matrix. Y can be a numeric array, datetime array, or logical array.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: thingSpeakPlot(x,y,'Color','red','LineStyle',':','Marker','o')

collapse all

Line color, specified as the comma-separated pair consisting of 'Color' and an RGB triplet or a color string. The default RGB triplet value of [0 0 1] corresponds to blue.

An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range [0,1], for example, [0.4 0.6 0.7]. This table lists RGB triplet values that have equivalent color strings.

Long NameShort NameRGB Triplet
'yellow''y'[1 1 0]
'magenta''m'[1 0 1]
'cyan''c'[0 1 1]
'red''r'[1 0 0]
'green''g'[0 1 0]
'blue''b'[0 0 1]
'white''w'[1 1 1]
'black''k'[0 0 0]

Example: thingSpeakPlot(x,y,'Color',[1 0 1])

Example: thingSpeakPlot(x,y,'Color','yellow')

Line style, specified as the comma-separated pair consisting of ‘LineStyle' and one of the line-style strings listed in this table.

StringLine StyleResulting Line
'-'Solid line

'--'Dashed line

':'Dotted line

'-.'Dash-dotted line

'none'No lineNo line

Line width, specified as a comma-separated pair consisting of "LineWidth' and the area outline width, specified as a positive scalar in points.

Example: thingSpeakPlot(x,y,'LineWidth',1.5);

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Marker symbol, specified as a comma-separated pair consisting of ‘Marker' and a marker symbol string listed in this table.

ValueDescription
'o'Circle
'+'Plus sign
'*'Asterisk
'.'Point
'x'Cross
'square' or 's'Square
'diamond' or 'd'Diamond
'^'Upward-pointing triangle
'v'Downward-pointing triangle
'>'Right-pointing triangle
'<'Left-pointing triangle
'pentagram' or 'p'Five-pointed star (pentagram)
'hexagram' or 'h'Six-pointed star (hexagram)
'none'No markers

Example: thingSpeakPlot(x, y,'Marker','p');

Y-axis scale, specified as a comma-separated pair consisting of ‘YScale' and a string. Allowed values are linear or log.

Example: thingSpeakPlot(x, y,'YScale','log');

Plot grid, specified as a comma-separated pair consisting of ‘Grid' and a string. Allowed values are 'on' or 'off'.

Example: thingSpeakPlot(x,y,'Grid','on');

Y-axis label, specified as a string.

Example: thingSpeakPlot(1:10,'XLabel','X-Axis');

X-axis label, specified as a comma-separated pair consisting of ‘XLabel' and characters indicating the X-axis label text.

Example: thingSpeakPlot(1:10,'YLabel','Y-Axis');

Title of plot, specified as a comma separated pair consisting of ‘Title' and characters indicating the title text.

Example: thingSpeakPlot(1:10,'Title','Plot Title');

Specify x-axis grid, consisting of a comma-separated pair consisting of ‘XGrid" and a string. Set the value to 'on' to display an x-axis grid.

Specify y-axis grid, consisting of a comma-separated pair consisting of ‘XGrid" and a string. Set the value to 'on' to display a y-axis grid.

Add a legend to your graph, specified as a comma-separated pair consisting of ‘Legend' and a cell array of strings.

Example: thingSpeakPlot(x,y,'Legend',{'Sine','Cosine','Tangent'})

Was this topic helpful?