【发布时间】:2017-12-28 11:47:39
【问题描述】:
我在 Matlab 中做了一个 3D 条形图。我希望每个组都使用相同的颜色(例如 s1=blue、s2=green 和 s3=red;见下图)
我使用了以下代码:
Z = data;
Y = [1 300 600]; % The positions of bars along the y axis
h = bar3(Y,Z',0.05);
[nGroup, nBar] = size(Z);
nColors = size(get(gcf, 'colormap'), 1);
colorInd = randi(nColors, nBar, nGroup);
for i = 1:nGroup
c = get(h(i), 'CData');
color = repelem(repmat(colorInd(:, i), 1, 4), 6, 1);
set(h(i), 'CData', color);
end
set(gca, 'YTickLabel',
有什么建议吗?
【问题讨论】:
标签: matlab plot colors bar-chart matlab-figure