scatter
Scatter plot: markers at given positions, with optional size and color for each point.
Category: Graphics > 2-D and 3-D Plots
Syntax
scatter(x, y)
Draws a circle at each point (x(k), y(k)).
scatter(x, y, sz)
Sets the marker area; a vector gives each point its own size.
scatter(x, y, sz, c)
Sets the color: a color spec, an RGB triplet, or a vector mapped through the colormap.
scatter(___, 'filled')
Fills the markers.
scatter(___, mkr)
Chooses the marker shape, such as 's' or '^'.
s = scatter(___)
Also returns the Scatter object.
Description
scatter is for relationships between variables where each point stands alone, and it can encode two more variables through size and color. For a plain line through the points, plot is lighter and faster.
Input arguments
x, y- Vectors of the same length.
sz- Marker area in points squared; scalar or one per point. The default is 36.
c- Color data. A vector of values is mapped through the current colormap.
Output arguments
s- Scatter object; read or change
SizeData,CData,MarkerFaceColorand more.
Example
Size and color per point
rng(1)
x = rand(1, 40);
y = x + 0.2*rand(1, 40);
scatter(x, y, 20 + 200*rand(1, 40), x, 'filled')
colorbar
In the app, the figure is drawn below the code.