2017-04-04 248 views

回答

4

您可以使用函数fill3并参考this answer for the 2D case来完成此操作,以了解如何在数据矢量的末端添加点以“关闭”填充的多边形。虽然创建一个图案(即阴影线)即使不是不可能也很困难,但另一种方法是简单地调整填充图片的alpha透明度。这里有一个简单的例子只是一个补丁:

x = 1:10; 
y = rand(1, 10); 
hFill = fill3(zeros(1, 12), x([1 1:end end]), [0 y 0], 'b', 'FaceAlpha', 0.5); 
grid on 

而这里的,这使得剧情:

enter image description here

您也可以在一个呼叫fill3创建多个补丁。这里有4套数据的例子:

nPoints = 10; % Number of data points 
nPlots = 4; % Number of curves 
data = rand(nPoints, nPlots); % Sample data, one curve per column 

% Create data matrices: 
[X, Y] = meshgrid(0:(nPlots-1), [1 1:nPoints nPoints]); 
Z = [zeros(1, nPlots); data; zeros(1, nPlots)]; 
patchColor = [0 0.4470 0.7410]; % RGB color for patch edge and face 

% Plot patches: 
hFill = fill3(X, Y, Z, patchColor, 'LineWidth', 1, 'EdgeColor', patchColor, ... 
       'FaceAlpha', 0.5); 
set(gca, 'YDir', 'reverse', 'YLim', [1 nPoints]); 
grid on 

而这里的,这使得剧情:

enter image description here

+0

非常感谢您!这帮助我很多! – Peter123