Hi everyone!
I've been using the bar command to make stacked graphs with no problems but when I try to make a one column stacked bar occurs the error 'X must be same length as Y.'
This is the code that I use and works for more than one column but not with one:
bar(1,[2 3], 'stacked')

 채택된 답변

Star Strider
Star Strider 2020년 3월 12일

0 개 추천

It is only possible to plot two stacked bars. Hiowever, after that, it is possible to turn one of them off.
Try this:
figure
hb = bar(([2; 3]*[1 1])', 'stacked');
hb(1).XData(2) = NaN;
hb(2).XData(2) = NaN;
There may be other ways to do it as well.

댓글 수: 2

Alexander Kurtz
Alexander Kurtz 2020년 3월 12일
it worked!
thank you very much
Star Strider
Star Strider 2020년 3월 12일
My pleasure!
If my Answer helped you solve your problem, please Accept it!

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

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Annotations에 대해 자세히 알아보기

질문:

2020년 3월 12일

댓글:

2020년 3월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by