필터 지우기
필터 지우기

Bar graph with unequal values.

조회 수: 1 (최근 30일)
Alexander Guillen
Alexander Guillen 2023년 9월 7일
댓글: Alexander Guillen 2023년 9월 7일
This is my code
clear all; close all; clc
a1 = [2 3 4 5 6];
a2 = 5;
b1 = [0.2 0.2 0.2 0.2 0.2];
b2 = 35;
bar(a1,b1)
hold on
bar(a2,b2)
At x = 5 ,the bar graph shows up as continous. Is there a way to to avoid this? I think this can be done by stacked but I am unsure.

채택된 답변

Adam Danz
Adam Danz 2023년 9월 7일
편집: Adam Danz 2023년 9월 7일
Are you expecting to see a stacked bar plot?
a1 = [2 3 4 5 6];
b1 = [0.2 0.2 0.2 0.2 0.2];
b2 = [nan nan nan 35 nan];
bar(a1,[b1;b2],'stacked')
Or are you expecting to see two axes?
figure()
tiledlayout(2,1)
a1 = [2 3 4 5 6];
a2 = 5;
b1 = [0.2 0.2 0.2 0.2 0.2];
b2 = 35;
ax1 = nexttile();
bar(a1,b1)
ax2 = nexttile();
bar(a2,b2)
linkaxes([ax1,ax2],'x')
  댓글 수: 1
Alexander Guillen
Alexander Guillen 2023년 9월 7일
Yes that is what I am looking for. Thank you!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by