フィルターのクリア

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 Center および File ExchangeBar Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by