【发布时间】:2019-09-09 01:47:41
【问题描述】:
Matlab colormap line plot 的答案解释了如何将颜色图与线图一起使用,但是如何将缩放的颜色条添加到图中,就像使用散点图一样?
xHorz = [0:0.001:2*pi];
nPts = numel(xHorz);
x = zeros(nPts,1);
x(:,1) = xHorz;
y = sin(x);
noiseMag = 1;
yNoise = y + noiseMag*randn(nPts,1);
winSizes = [100:100:2000];
nWins = numel(winSizes);
ySm = zeros(nPts,nWins);
for iWin = 1:nWins
ySm(:,iWin) = smoothdata(yNoise,'loess',winSizes(iWin));
end
xScatter = repmat(x,1,nWins);
zScatter = repmat(winSizes,nPts,1);
f1 = figure;
scatter3(xScatter(:),zScatter(:),ySm(:),2,zScatter(:),'filled')
cbar = colorbar;
cbar.Label.String = 'Smoothing Window Size';
f2 = figure;
lineColors = parula(nWins);
for iWin = 1:nWins
plot(x,ySm(:,iWin),'Color',lineColors(iWin,:),'LineWidth',2);
hold on
end
没有颜色条的二维线:
带颜色条的 3D 散点图:
我相信smoothdata() 功能需要 R2017a 或更高版本。
【问题讨论】:
标签: matlab data-visualization matlab-figure colorbar colormap