필터 지우기
필터 지우기

How to add a line break in categorical array?

조회 수: 15 (최근 30일)
Vidura Vishvanath
Vidura Vishvanath 2022년 7월 14일
답변: the cyclist 2022년 7월 14일
I want to add a line break between the season and months in the following bar chart. For example,
First Inter-monsoon
(March - April)
Any help is appreciated.
X = categorical({'First Inter-monsoon (March - April)','Southwest-monsoon (May - September)','Second Inter-monsoon (October-November)','Northeast-monsoon (December - February)'});
Y = [89 165 128 78; 41 106 54 38; NaN NaN 2.1 1.4];
b=bar(X,Y,'LineWidth',1)
b =
1×3 Bar array: Bar Bar Bar
colororder('default')

채택된 답변

the cyclist
the cyclist 2022년 7월 14일
Here is one way:
X = categorical({sprintf('First Inter-monsoon\\newline (March - April)'), ...
sprintf('Southwest-monsoon\\newline (May - September)'), ...
sprintf('Second Inter-monsoon\\newline (October-November)'), ...
sprintf('Northeast-monsoon\\newline (December - February)')});
Y = [89 165 128 78; 41 106 54 38; NaN NaN 2.1 1.4];
figure
b=bar(X,Y,'LineWidth',1);
colororder('default')

추가 답변 (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