【问题标题】:Filling between two lines在两行之间填充
【发布时间】:2016-04-11 17:39:01
【问题描述】:

我已经根据一些分散的点绘制了两条线,但是,我现在需要填充两条线之间的区域。

counts_dataset = dataset('file','file.txt','Delimiter','\t');
x = counts_dataset.x;
y1 = counts_dataset.y1;
y2 = counts_dataset.y2;

line1 = line(x, y1,'Color', [.8 .8 .8])
line2 = line(x, y2,'Color', [.8 .8 .8])

我现在尝试这样填充两行之间的区域:

fill([x fliplr(x)],[y2 fliplr(y1)],'c')

但是,这给了我这个情节:

忽略散点

我是否错误地使用了填充功能?如何在两条线之间着色?

【问题讨论】:

标签: matlab plot matlab-figure


【解决方案1】:

您的数据可能有问题。以下代码完全符合您的要求:

x = 1:10;
y1 = sin(x) + 3;
y2 = sin(x);
fill([x fliplr(x)], [y2 fliplr(y1)], 'c')

【讨论】:

  • 谢谢。我会调查的
猜你喜欢
  • 2020-09-16
  • 2021-07-12
  • 1970-01-01
  • 1970-01-01
  • 2017-11-28
  • 2014-11-04
  • 2020-12-11
相关资源
最近更新 更多