how to plot side by side bar chart on the same axis?

3 次查看(过去 30 天)
I would like to have bar side by side for M1 on the left side of the figure and then likewise for M2 on the right side. M1 has 10 columns-so the plot be constructed in such a way that column 1 is aside with column 6 of M1. similarly, column 2 of M1 in comparison with column 7 of M1. I want the same for M2 but on the right side of the figure (i.e. there should be a gap between M1 and M2 dataset) see attached image as an example (i don't want bar stacked and have only two time periods correspond to M1 and M2). I tried the following but am not getting anywhere
M1 = -5 + (5+5)*rand(1,10);
M2= -5 + (5+5)*rand(1,10);
figure()
bar([M1(:,1:5);M1(:,6:10)])
hold on
yyaxis right
bar([M2(:,1:5);M2(:,6:10)])
  1 个评论
James Knowles
James Knowles 2018-1-4
This in built function may be of some use https://au.mathworks.com/help/matlab/ref/subplot.html

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Histograms 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by