2016-04-11 76 views
0

我已經根據一些散點繪製了兩條線,但是現在我需要填充兩條線之間的區域。在兩條線之間填充

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') 

然而,這給了我這樣的情節:enter image description here

不顧散點

我是否正確使用填充功能?我怎樣才能遮蔽兩條線?

+0

相關:http://stackoverflow.com/questions/7350140/two-time-series-plots-and-shading-between-them- matlab – Amro

回答

1

可能您的數據有問題。下面的代碼不正是你想要什麼:

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

Resulting plot

+0

謝謝。我會研究它 – interstellar