MATLAB条形图:如何组合条形图?

时间:2016-12-03 05:23:34

标签: matlab

很抱歉这个简单的问题,但我无法弄清楚如何在MATLAB上组合条形图。现在,我有以下两个条形图,我试图合并:

第一

first

第二

enter image description here

我想要做的就是将两个图组合起来,使所有信息保持不变,唯一的区别是所有sigmas和gamma都在同一个x轴上。有人可以帮助我或给我一个参考资料,我可以找到这个问题的答案吗?

谢谢

1 个答案:

答案 0 :(得分:0)

在Matlab中查看Bar graph上的示例。你可以使用一组条堆积条,但我想你需要的是一组条。我就是这里的一个例子。

示例:使用bar(...)获取所需的结果类型。请考虑以下代码,结果如下所示:

% Make some play data:
x = randn(100,3);
[y, b] = hist(x);

% You can plot on your own bar chart:
figure(82);
bar(b,y,'grouped');
title('Grouped bar chart');

% Consider stack for the other type:
figure(83);
bar(b,y,'stacked');
title('Stacked bar chart');

enter image description here

enter image description here

您还可以使用hist(...)

% Bust histogram will work here:
figure(44);
hist(x);
title('Histogram Automatically Grouping');

enter image description here

  

更新

您可以通过组合两个条形图的数据来绘制单个条形图。您可以根据需要设置x轴值。见example。要在Bar graph中设置轴值,您可以看到此video tutorial