addpoints
Add points to animated line
Description
addpoints(
adds points defined by an
,x
,y
)x
and y
to the animated
line specified by an
. Create an animated line with the animatedline
function. To display
the updates on the screen, use drawnow
or drawnow
limitrate
. New points automatically connect to previous points.
Examples
Add Five Points to Animated Line
Create an animated line object with no data. Then, add five points to the line. Use a circle to mark each point.
h = animatedline('Marker','o'); x = 1:5; y = 1:5; addpoints(h,x,y)
Specify Datetime and Duration Values
To plot nonnumeric points, such as datetime and duration values, start by initializing the animated line with values of the type you want to plot. You can specify either the first point in your plot or placeholder values such as NaT
or NaN
.
For example, plot datetime values on the x-axis and duration values (minutes) on the y-axis. Initialize the animated line with a NaT
value and a minutes(NaN)
value. Then create a datetime vector (x
) and a duration vector (y
) and add the points in those vectors to the animated line.
an = animatedline(NaT,minutes(NaN),"Marker","o"); x = datetime(2018,5,1:5); y = minutes([1 7 3 11 4]); addpoints(an,x,y)
Add Points Within Loop to Animated Line
Create an animated line using the animatedline
function. Then, add points to the line within a loop to create an animation. Set the axis limits before the loop to prevent the limits from changing.
figure h = animatedline; axis([0 4*pi -1 1]) for x = linspace(0,4*pi,10000) y = sin(x); addpoints(h,x,y) drawnow limitrate end
Input Arguments
an
— AnimatedLine
object
AnimatedLine
object
AnimatedLine
object. Create an AnimatedLine
object using the animatedline
function.
x
— First coordinate values
scalar | vector
First coordinate values, specified as a scalar or a vector. For Cartesian axes, the first coordinate is x-axis position. For geographic axes, the first coordinate is latitude in degrees.
The length of x
must equal the length of
y
.
Example: 11:20
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| datetime
| duration
y
— Second coordinate values
scalar | vector
Second coordinate values, specified as a scalar or a vector. For Cartesian axes, the second coordinate is y-axis position. For geographic axes, the second coordinate is longitude in degrees.
The length of y
must equal the length of
x
.
Example: 11:20
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| datetime
| duration
z
— Third coordinate values
scalar | vector
Third coordinate values, specified as a scalar or a vector. For Cartesian axes, the third coordinate is z-axis position.
The length of z
must equal the length of
x
and y
.
Example: 11:20
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| datetime
| duration
Extended Capabilities
GPU Arrays
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
The addpoints
function
supports GPU array input with these usage notes and limitations:
This function accepts GPU arrays, but does not run on a GPU.
For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
Distributed Arrays
Partition large arrays across the combined memory of your cluster using Parallel Computing Toolbox™.
Usage notes and limitations:
This function operates on distributed arrays, but executes in the client MATLAB®.
For more information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox).
Version History
Introduced in R2014bR2023a: Specify single, double, integer, datetime, or duration coordinates
Add points to animated lines using single, double, integer, datetime, or duration data for the x-, y-, and z-coordinates.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)