MATLAB 多条曲线之间的着色区域

标签 matlab plot curve region shading

此网站上已经有很多类似问题的问题:

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 条曲线需要类似的东西。

最佳答案

如果我理解正确,您可以通过创建要着色的区域的 minmax 向量并使用 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')

enter image description here

关于MATLAB 多条曲线之间的着色区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42403461/

相关文章:

python - 动画 matplotlib 参数化示例

java - 检查曲线是否闭合

c++ - 如何将 Mat H=findHomography 返回给 Matlab

matlab - 修改记事本文本

产生闭区间随机实数的matlab函数

R:将平均绩点可视化为(某种) fiddle 图

matlab - 从 Matlab 中更改 DISPLAY 变量

r - 找不到函数 plot.gam

python - 使用 Pandas 从数据透视表中绘制

canvas - 如何找出 Canvas 中贝塞尔曲线中特定点的Y坐标?