필터 지우기
필터 지우기

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

조회 수: 3 (최근 30일)
Hydro
Hydro 2017년 12월 30일
댓글: James Knowles 2018년 1월 4일
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에서 Bar Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by