Fixing the legend of a bar graph

2 ビュー (過去 30 日間)
Alberto Acri
Alberto Acri 2023 年 8 月 6 日
回答済み: the cyclist 2023 年 8 月 6 日
Hi! I need to better arrange the legend of a bar graph. It is currently plotted like this:
load CountArray_A.mat
x = CountArray_A(:,1).';
y = CountArray_A(:,2);
figure();
graph = barh(x,y,'FaceColor',[1 0 0],'EdgeColor',[0 0 0]);
name = "saagagagasgadgadgadg ddsbds fbsfs sdbsdsz dhwh ddadgada adggdv";
legend({name},'Location','northeast','Orientation','horizontal')
I would like to either change the legend like this (if possible):

採用された回答

the cyclist
the cyclist 2023 年 8 月 6 日
Here is one way:
load CountArray_A.mat
x = CountArray_A(:,1).';
y = CountArray_A(:,2);
figure();
graph = barh(x,y,'FaceColor',[1 0 0],'EdgeColor',[0 0 0]);
name = "saagagagasgadgadgadg" + newline + "ddsbds fbsfs sdbsdsz dhwh ddadgada adggdv"; % Added newline
legend(name,'Location','northeast','Orientation','horizontal') % Removed unnecessary cell

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLegend についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by