fill3
并参考 这个回答中的 2D 情况,了解如何在数据向量的末尾添加点以“关闭”填充多边形。虽然创建图案(即剖线)可能很难甚至不可能,但另一种选择是简单地调整填充补丁的 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
这是它所呈现的情节:
您可以在一次调用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
这是它所呈现的情节: