How to set Categories consistent when using "signalMask" and "plotsigroi" ?

2 ビュー (過去 30 日間)
Mibang
Mibang 2024 年 3 月 7 日
回答済み: Drishti 2024 年 8 月 12 日
I want to plot using the code below with the loaded mat file attached.
For example, when "m1=200" I obtain the attached figure.
But, the issue is that, the cetegories are not the same order between two subplots.
I want the categories being the same order, e.g., "n/a", "N", "V", "A" in both subplots.
I would appreciate it if you could help me how to do it.
Thank you,
%%
load qNa.mat
m1=200;
figure;
M = signalMask(tl{m1}); subplot(2,1,1);
p1 = plotsigroi(M,G2{m1});
ls = p1.Children;
for i2=1:size(ls,1)
ls(i2).LineWidth = 2.0;
end
srt = sprintf('N only w/GT, data-%d ',m1);
title(srt)
M = signalMask(pl{m1}); subplot(2,1,2);
p2 = plotsigroi(M,G2{m1});
ls = p2.Children;
for i2=1:size(ls,1)
ls(i2).LineWidth = 2.0;
end
srt2 = sprintf('N only w/Est, data-%d',m1);
title(srt2)
  1 件のコメント
Mibang
Mibang 2024 年 3 月 7 日
編集済み: Mibang 2024 年 3 月 7 日
I got an answer from a staff memeber of MathWorks as below to share:
...
C = reordercats(tl{m1}, ["n/a", "A", "N", "V"])
M = signalMask(C); subplot(2,1,1);
p1 = plotsigroi(M,G2{m1});
...

サインインしてコメントする。

回答 (1 件)

Drishti
Drishti 2024 年 8 月 12 日
Hi Mibang,
I understand that you are encountering an issue with setting the categories of the subplot while using the functions ‘signalMask’ and ‘plotsigroi’ in MATLAB R2023b.
To address this, you can use the ‘reordercats’ function. This function is useful when you need to specify a custom order for the categories.
Furthermore, refer to the example code provided below
% Reorder categories for the first subplot
C = reordercats(tl{m1}, ["n/a", "N", "V", "A"]); %custom order for categories
M = signalMask(C);
subplot(2,1,1);
p1 = plotsigroi(M, G2{m1});
ls = p1.Children;
for i2 = 1:size(ls, 1)
ls(i2).LineWidth = 2.0;
end
srt = sprintf('N only w/GT, data-%d ', m1);
title(srt);
For more information, you can refer to the MATLAB Documentation of the ‘reordercats’ function.
I hope this helps.

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by