此网站上已经有很多类似问题的问题:
MATLAB, Filling in the area between two sets of data, lines in one figure
MATLAB fill area between lines
但是,所有现有问题仅与两条曲线有关。如何填充由相互重叠的几条曲线界定的区域?
一个粗略的例子是:
% Create sample data as column vectors.
x = [1 : 100]';
curve1 = x/10;
curve2 = log(x/2) + rand(length(x), 1) - 0.5;
curve3 = log(x) + rand(length(x), 1) + 0.5;
% Plot it.
plot(x, curve1, 'r', 'LineWidth', 2);
hold on;
plot(x, curve2, 'b', 'LineWidth', 2);
plot(x, curve3, 'k', 'LineWidth', 2);
对于阴影: 上限是黑色曲线,后面是红线。
下限将是蓝色曲线(短暂),然后是红线,最后是蓝色曲线。
在我的实际数据集中,我有 10 条曲线需要类似的东西。
最佳答案
如果我理解正确,您可以通过创建要着色的区域的 min
和 max
向量并使用 flipud
来实现此目的code> 使用 fill
min_data=min([curve1,curve2,curve3],[],2);
max_data=max([curve1,curve2,curve3],[],2);
fill([x;flipud(x)],[min_data;flipud(max_data)],'g')
关于MATLAB 多条曲线之间的着色区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42403461/