如何绘制3D的trace?
效果如下:
代码如下:
% 绘制3D的trace
% 效果如图所示:
% ![](https://imagewwyt-1312423176.cos.ap-guangzhou.myqcloud.com/img/202301081214600.png)
clear;clc;close all;
% 获取到颜色
% [all_themes, all_colors] = GetColors();
figure;
x = -20:10:20;
y = linspace(0, 10, 100);
% 生成 5 组数据
z = zeros(5, 100);
z(1, :) = gaussmf(y, [0.5 3]);
z(2, :) = gaussmf(y, [0.6 4]);
z(3, :) = gaussmf(y, [0.7 5]);
z(4, :) = gaussmf(y, [0.8 6]);
z(5, :) = gaussmf(y, [0.9 7]);
for i = 1:5
% x 方向每条曲线都是一个值
xx = x(i)*ones(1, 100); % 偏移
% z 方向的值,每次取一条
zz = z(i, :); %
% plot3 在 xyz 空间绘制曲线,保证 x y z 长度一致即可
plot3(xx, y, zz, 'LineWidth', 2);
hold on
end
hold off
% 定制颜色
% set(gca, 'colororder', all_themes{1});
legend('line1', 'line2', 'line3', 'line4', 'line5');
参考这个博客:
https://www.zhihu.com/question/268877581/answer/2277678667