MATLAB scatter Function
Aug. 30, 2022 • Updated Oct. 23, 2024
Fundamentals
scatter绘图函数示例:
1
2
3
4
5
6
7
8
9
clc, clear, close
% Points
data = randn(1,20);
% Plot
figure, axes
hold(gca, "on")
scatter(1:numel(data), data, 200, 'rx', LineWidth=2)

其中:
(1)1:numel(data)和data分别表示数据点的x-coordinates和y-coordinates;
(2)200表示marker的大小,必须直接跟在数据点之后;
(3)'rx':其中r表示marker的颜色,x表示marker的形状;
(4)LineWidth=2表示marker的粗细;
'filled' parameter
当使用类似x这样只有只有face没有edges的marker,使用filled参数将会什么也不绘制。
1
2
3
4
5
6
7
8
9
clc, clear, close
% Points
data = randn(1,20);
% Plot
figure, axes
hold(gca, "on")
scatter(1:numel(data), data, 200, 'filled', 'rx', LineWidth=2)

There’s noting,而且也不报错。类似marker还有:'+', '*', '.'。
References